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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --border: #2e3340;
  --primary: #6c8aff;
  --primary-hover: #8aa2ff;
  --text: #e4e6ed;
  --text-muted: #8b8fa4;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --radius: 12px;
}

body {
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

header .logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

header h1 span {
  color: var(--text-muted);
  font-weight: 400;
}

header .user-section {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

header .user-profile {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  object-fit: cover;
}

header .logout-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

header .logout-btn:hover {
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.3);
}

/* Auth Loading State */
body.auth-loading > *:not(.auth-splash) {
  display: none !important;
}

.auth-splash {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

body.auth-loading .auth-splash {
  display: flex;
}

.auth-splash .splash-logo {
  height: 80px;
  width: auto;
}

.auth-splash .splash-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.auth-splash .splash-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: authSpin 0.8s linear infinite;
}

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

body {
  transition: opacity 0.3s ease;
}

/* Keyboard navigation: visible focus ring on interactive elements */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Conversion Counter Banner ── */
.conversion-banner {
  background: linear-gradient(135deg, rgba(108, 138, 255, 0.12), rgba(138, 162, 255, 0.06));
  border-bottom: 1px solid var(--border);
  padding: 10px 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
}

.conversion-banner .counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.conversion-banner .counter-pill .count {
  color: var(--primary);
  font-size: 16px;
}

.conversion-banner .counter-pill.exhausted .count {
  color: var(--error);
}

.conversion-banner .counter-label {
  color: var(--text-muted);
}

.conversion-banner.exhausted {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.1), rgba(248, 113, 113, 0.04));
}

.conversion-banner.exhausted .counter-label {
  color: var(--error);
}

/* Code Redemption Input */
.code-redeem-section {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-left: 16px;
}

@media (max-width: 600px) {
  .code-redeem-section {
    margin-left: 0;
  }
}

.code-redeem-section.visible {
  display: flex;
}

.code-redeem-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.05em;
  width: 170px;
  outline: none;
  transition: border-color 0.2s;
}

.code-redeem-input:focus {
  border-color: var(--primary);
}

.code-redeem-btn {
  background: linear-gradient(135deg, var(--primary), #8aa2ff);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.code-redeem-btn:hover {
  opacity: 0.85;
}

.code-redeem-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.code-msg {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  display: none;
}

.code-msg.success {
  display: inline;
  color: var(--success);
}

.code-msg.error {
  display: inline;
  color: var(--error);
}

.request-access-link {
  display: none;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 6px;
  white-space: nowrap;
  opacity: 0.8;
  transition: opacity 0.2s;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

.request-access-link:hover {
  opacity: 1;
  color: var(--primary);
}

.code-redeem-section.visible .request-access-link {
  display: inline;
}

/* ── Request Access Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

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

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 420px;
  max-width: 90vw;
  padding: 32px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  animation: modalSlide 0.3s ease;
}

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

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

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--border);
}

.modal-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-form input,
.modal-form textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.modal-form input:focus,
.modal-form textarea:focus {
  border-color: var(--primary);
}

.modal-form textarea {
  resize: vertical;
  min-height: 70px;
}

.modal-submit {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary), #8aa2ff);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal-submit:hover {
  opacity: 0.9;
}

.modal-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-success {
  text-align: center;
  padding: 20px 0;
}

.modal-success .checkmark {
  font-size: 48px;
  margin-bottom: 10px;
}

.modal-success p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Main Layout ── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 20px;
  padding: 24px 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.main-left-col,
.main-right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-self: start;
}

/* ── Drop Zone ── */
.drop-zone {
  grid-column: 1 / -1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(108, 138, 255, 0.06);
}

.drop-zone.drag-over {
  transform: scale(1.005);
}

.drop-zone.has-file {
  padding: 16px 24px;
  border-style: solid;
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.05);
  cursor: default;
}

.drop-zone.limit-reached {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none;
  position: relative;
}

.drop-zone .icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.drop-zone .label {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
}

.drop-zone .sublabel {
  font-size: 13px;
  color: var(--text-muted);
}

.drop-zone .file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.drop-zone .file-info .file-name {
  font-weight: 600;
}

.drop-zone .file-info .file-size {
  color: var(--text-muted);
}

.drop-zone .file-info .change-btn {
  margin-left: auto;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.drop-zone .file-info .change-btn:hover {
  background: var(--border);
}

.drop-zone input[type="file"] {
  display: none;
}

/* ── 3D Preview ── */
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Scale with the viewport instead of a fixed 623px (≈623px at 1080p) */
  height: clamp(420px, 70vh, 760px);
}

.panel-header {
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.preview-canvas-wrap {
  flex: 1;
  position: relative;
  /* Soft light gray instead of pure white — keeps dental contrast while
     easing the jump from the dark theme (must match scene.background) */
  background: #f4f6f9;
}

.preview-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Metadata + Controls ── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metadata-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.meta-item {
  padding: 10px 14px;
  background: var(--surface);
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--text-muted);
  color: var(--surface);
  font-size: 10px;
  font-weight: bold;
  cursor: default;
  opacity: 0.7;
  transition: opacity 0.2s;
  position: relative;
}

.info-icon:hover,
.info-icon:focus,
.info-icon:focus-within {
  opacity: 1;
  z-index: 999;
  /* Lift the icon's stacking context above standard page elements so the tooltip doesn't get clipped */
}

.tooltip-text {
  visibility: hidden;
  width: 250px;
  background-color: var(--surface);
  color: var(--text);
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  position: absolute;
  z-index: 100;
  top: 150%;
  left: 0;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.tooltip-text::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 10px;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent var(--border) transparent;
}

/* Show on hover (mouse), focus (keyboard Tab), and tap (touch focuses the
   tabindex element) so the reference is reachable on every device */
.info-icon:hover .tooltip-text,
.info-icon:focus .tooltip-text,
.info-icon:focus-within .tooltip-text {
  visibility: visible;
  pointer-events: auto;
}

.meta-item .meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.meta-item .meta-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.meta-item.full-width {
  grid-column: 1 / -1;
}

.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: space-between;
  position: relative;
}

.fit-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 287px;
  justify-content: space-between;
  position: relative;
}

.fit-panel .panel-header {
  padding: 0;
  border: none;
  margin-bottom: 0px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-row .cb-text .cb-label {
  font-weight: 500;
}

.checkbox-row .cb-text .cb-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Progress Bar ── */
.progress-wrap {
  display: none;
  position: absolute;
  bottom: 56px;
  left: 18px;
  right: 18px;
  padding: 12px;
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.progress-wrap.visible {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Status Log ── */
.log-panel {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.log-body {
  padding: 14px 18px;
  max-height: 160px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.7;
}

.log-body::-webkit-scrollbar {
  width: 6px;
}

.log-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.log-entry {
  display: flex;
  gap: 10px;
}

.log-entry .log-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-entry.info .log-msg {
  color: var(--text);
}

.log-entry.success .log-msg {
  color: var(--success);
}

.log-entry.error .log-msg {
  color: var(--error);
}

.log-entry.warn .log-msg {
  color: var(--warning);
}

/* ── Step Indicator ── */
.step-indicator {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 0 4px 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.3s ease;
  position: relative;
}

.step .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.step.active {
  color: var(--primary);
}

.step.active .step-num {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(108, 138, 255, 0.4);
}

.step.done {
  color: var(--success);
}

.step.done .step-num {
  background: var(--success);
  color: #fff;
}

.step-connector {
  width: 40px;
  height: 2px;
  background: var(--border);
  transition: background 0.3s ease;
}

.step-connector.done {
  background: var(--success);
}

/* ── Drop Zone Animations ── */
@keyframes dropPulse {
  0%, 100% { border-color: var(--primary); box-shadow: 0 0 0 0 rgba(108, 138, 255, 0.3); }
  50% { border-color: var(--primary-hover); box-shadow: 0 0 0 8px rgba(108, 138, 255, 0); }
}

.drop-zone.drag-over {
  animation: dropPulse 1.2s ease infinite;
}

@keyframes fileLoaded {
  0% { transform: scale(1); }
  30% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.drop-zone.has-file {
  animation: fileLoaded 0.4s ease;
}

/* ── Better Preview Placeholder ── */
.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
  background: linear-gradient(135deg, #1a1d27 0%, #0f1117 100%);
}

.preview-placeholder .placeholder-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(108, 138, 255, 0.08);
  border: 2px dashed rgba(108, 138, 255, 0.2);
  display: grid;
  place-items: center;
  animation: placeholderFloat 3s ease-in-out infinite;
}

.preview-placeholder .placeholder-icon svg {
  width: 32px;
  height: 32px;
  opacity: 0.5;
}

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

.preview-placeholder .placeholder-text {
  font-weight: 500;
}

.preview-placeholder .placeholder-hint {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Collapsible Metadata ── */
.meta-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  cursor: pointer;
  border-top: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  transition: background 0.15s;
  user-select: none;
}

.meta-toggle:hover {
  background: var(--surface-hover);
}

.meta-toggle .toggle-arrow {
  transition: transform 0.2s ease;
  font-size: 10px;
}

.meta-toggle.expanded .toggle-arrow {
  transform: rotate(180deg);
}

.meta-extra {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.meta-extra.expanded {
  max-height: 500px;
}

/* ── Sticky Convert Button ── */
.convert-btn {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary), #8aa2ff);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: sticky;
  bottom: 16px;
  z-index: 5;
  box-shadow: 0 4px 20px rgba(108, 138, 255, 0.3);
}

.convert-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), #a0b5ff);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108, 138, 255, 0.45);
}

.convert-btn:active:not(:disabled) {
  transform: translateY(0);
}

.convert-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--border);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.35s ease, toastOut 0.3s ease 3.5s forwards;
  pointer-events: auto;
  max-width: 360px;
}

.toast .toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ── Skeleton Loading ── */
.meta-value.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  color: transparent !important;
  min-width: 60px;
  display: inline-block;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Animated Number Counter ── */
.meta-value {
  transition: color 0.2s ease;
}

/* ── Inline Styles → Classes ── */
.controls-panel-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.shrinkage-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.offset-select {
  width: 100%;
  padding: 13px 12px;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 4px;
  cursor: pointer;
  /* Custom chevron — appearance:none removes the native dropdown arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b8fa4' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.opacity-controls {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.slider-group { margin-bottom: 12px; }
.slider-group:last-child { margin-bottom: 0; }

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.slider-input {
  width: 100%;
}

.fit-panel-header {
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  border: none;
  margin-bottom: 0;
}

.view-mode-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.view-mode-select {
  width: 100%;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b8fa4' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.shell-opacity-wrap {
  margin-bottom: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.force-legend {
  background: rgba(108, 138, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-top: auto;
}

.force-legend-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.force-legend-body {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}

.side-by-side-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  grid-column: 1 / -1;
}

.dental-panel-header { color: #a78bfa; }
.converted-panel-header { color: var(--success); }
.dental-border { border-color: #a78bfa; }
.converted-border { border-color: var(--success); }

/* ── Comparison Table ── */
.comparison-panel {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: none;
}

.comparison-panel.visible { display: block; }

.comparison-panel .panel-header {
  color: var(--primary);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
}

.compare-table th,
.compare-table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.compare-table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg);
}

.compare-table td {
  font-variant-numeric: tabular-nums;
}

.compare-table td:first-child {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.compare-table .delta {
  font-weight: 600;
  font-size: 12px;
}

.compare-table .delta.negative { color: var(--error); }
.compare-table .delta.positive { color: var(--success); }
.compare-table .delta.neutral { color: var(--text-muted); }

.compare-table tr:last-child td { border-bottom: none; }

/* ── Measurement Tool ── */
.measure-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 6px;
}

.measure-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.measure-btn:hover { background: var(--surface-hover); color: var(--text); }
.measure-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.measure-label {
  position: absolute;
  background: rgba(15, 17, 23, 0.9);
  border: 1px solid #ffd700;
  color: #ffd700;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
  z-index: 20;
  transform: translate(-50%, -100%);
  margin-top: -8px;
}

/* ── Screenshot Export ── */
.screenshot-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1001;
  align-items: center;
  justify-content: center;
}

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

.screenshot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 900px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlide 0.3s ease;
}

.screenshot-preview {
  display: flex;
  gap: 16px;
  margin: 16px 0;
}

.screenshot-preview canvas,
.screenshot-preview img {
  border-radius: 8px;
  border: 1px solid var(--border);
  max-width: 100%;
}

.screenshot-meta-overlay {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

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

.screenshot-actions button {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #8aa2ff);
  color: #fff;
  border: none;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
}

/* ── Conversion History ── */
.history-panel {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: none;
}

.history-panel.visible { display: block; }

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg);
}

.history-table td {
  font-variant-numeric: tabular-nums;
}

.history-table tr:last-child td { border-bottom: none; }

.history-table .download-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.history-table .download-link:hover { text-decoration: underline; }

.history-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(108, 138, 255, 0.1);
  color: var(--primary);
}

/* ── Heatmap ── */
.heatmap-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.heatmap-toggle {
  width: 100%;
  padding: 8px 14px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.heatmap-toggle:hover { background: var(--border); color: var(--text); }
.heatmap-toggle.active {
  background: linear-gradient(135deg, #3b82f6, #22c55e, #eab308, #ef4444);
  color: #fff;
  border-color: transparent;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.heatmap-legend {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.heatmap-legend.visible { display: block; }

.heatmap-legend-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.heatmap-gradient-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(to right, #3b82f6, #06b6d4, #22c55e, #eab308, #ef4444);
  margin-bottom: 6px;
}

.heatmap-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.heatmap-labels .hm-min { color: #3b82f6; }
.heatmap-labels .hm-max { color: #ef4444; }

/* ── Log Panel Collapsible ── */
.log-panel .panel-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.log-panel .panel-header:hover {
  background: var(--surface-hover);
}

.log-body.collapsed {
  max-height: 0;
  padding: 0 18px;
  overflow: hidden;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.footer-brand .footer-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.footer-brand span {
  font-weight: 600;
  color: var(--text);
}

.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

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

.footer-contact a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

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

/* ── Guide Modal ── */
.guide-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1002;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlide 0.3s ease;
}

.guide-card .guide-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  border-radius: 16px 16px 0 0;
}

.guide-card .guide-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.guide-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.guide-close:hover { background: var(--surface-hover); color: var(--text); }

.guide-steps {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.guide-step-num {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--primary), #8aa2ff);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.guide-step-body h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.guide-step-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.guide-step-body kbd {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--primary);
}

.guide-footer-link {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
}

.guide-footer-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.guide-footer-link a:hover { text-decoration: underline; }

.how-to-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.how-to-btn:hover {
  background: rgba(108, 138, 255, 0.1);
  color: var(--primary);
  border-color: rgba(108, 138, 255, 0.3);
}

/* ── Responsive ── */
@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .main-left-col,
  .main-right-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .drop-zone {
    grid-column: 1 / -1;
  }

  .log-panel {
    grid-column: 1 / -1;
  }

  .preview-panel {
    min-height: 300px;
    height: auto;
    max-height: 50vh;
  }

  .step { padding: 8px 10px; font-size: 12px; }
  .step .step-label { display: none; }
  .step-connector { width: 24px; }

  .side-by-side-panels { grid-template-columns: 1fr; }

  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: 100%; }
  .site-footer { flex-direction: column; text-align: center; padding: 20px 16px; }
  .footer-links { justify-content: center; }
}

/* ── Brand mark + wordmark ── */
.logo-text {
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--primary);
  white-space: nowrap;
}
header .logo.logo-text { height: auto; font-size: 15px; padding-right: 14px; border-right: 1px solid var(--border); display: inline-flex; align-items: center; gap: 10px; }
/* The stamp artwork is circular on a paper background, so it is shown as a round badge */
.logo-mark, .splash-mark { border-radius: 50%; flex-shrink: 0; }
.splash-mark { margin-bottom: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.auth-splash .splash-logo.logo-text { height: auto; font-size: 28px; }

.control-hint {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 8px 0 4px;
}

/* ── Shrinkage simulation controls ── */
.sim-group {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-bottom: 12px;
}
.sim-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.sim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sim-row .slider-input { flex: 1; }
.sim-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 8px;
  cursor: pointer;
}
.sim-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.sim-btn:hover { border-color: var(--primary); }
.sim-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.sim-check { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); cursor: pointer; }
.fit-panel :disabled { opacity: 0.45; cursor: not-allowed; }

.section-body { display: none; }
.section-body.open { display: block; }
.section-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.swatch-orig { background: #4a90e2; }
.swatch-shrunk { background: #f97316; }
.swatch-folded { background: #d946ef; }
.section-gap { font-size: 12px; color: var(--text); line-height: 1.45; font-variant-numeric: tabular-nums; }

.sim-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 10;
  background: rgba(249, 115, 22, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  pointer-events: none;
}
.sim-badge[hidden] { display: none; }

.force-legend { margin-bottom: 12px; }
.force-legend-body .check-warn { color: var(--warning); }
.force-legend-body .check-row { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.force-legend-body .check-row span:first-child { color: var(--text-muted); }

/* Heatmap: diverging ramp centred on the selected offset (mm mode) */
.heatmap-gradient-bar.ramp-target {
  background: linear-gradient(to right, #ef4444, #f59e0b 33.3%, #22c55e 66.7%, #3b82f6);
}
.heatmap-labels { position: relative; }
.heatmap-labels .hm-mid { position: absolute; left: 66.7%; transform: translateX(-50%); color: #22c55e; }
.heatmap-labels .hm-min.ramp-target { color: #ef4444; }
.heatmap-labels .hm-max.ramp-target { color: #3b82f6; }
.hm-folded { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Shrinkage check while the worker recomputes the offset */
#shrinkCheckText.updating { opacity: 0.5; transition: opacity 0.15s; }

/* ── Upper + lower pair ── */
.drop-zone .file-info { flex-wrap: wrap; align-items: flex-start; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; flex: 1 1 260px; min-width: 0; }
.file-list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.drop-zone .file-info .file-list .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.arch-role { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(108, 138, 255, 0.15); color: var(--primary); }
.file-remove { flex-shrink: 0; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.file-remove:hover, .file-remove:focus-visible { color: var(--error); background: var(--surface-hover); }
.file-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.drop-zone .file-info .file-actions .change-btn { margin-left: 0; }
.file-actions .change-btn[hidden] { display: none; }
.arch-switch { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-hover); border: 1px solid var(--border); border-radius: 8px; }
.arch-switch[hidden] { display: none; }
.arch-switch button { border: none; background: none; color: var(--text-muted); font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.arch-switch button[aria-selected="true"] { background: var(--primary); color: #fff; }
.arch-tag:not(:empty)::before { content: " — "; }
.arch-tag { color: var(--primary); }
#pairHint[hidden] { display: none; }
