@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@200;700&display=swap');

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

:root {
  /* Colors */
  --color-primary: #667eea;
  --color-primary-dark: #764ba2;
  --color-error: #ef4444;
  --color-error-light: #f87171;
  --color-warning: #f59e0b;
  --color-warning-light: #fbbf24;
  --color-success: #22c55e;
  --color-success-light: #4ade80;
  --color-info: #3b82f6;
  --color-info-light: #60a5fa;
  --color-export: #10b981;
  --color-export-dark: #059669;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  --gradient-export: linear-gradient(135deg, var(--color-export), var(--color-export-dark));

  /* Surfaces */
  --bg-elevated: rgba(255,255,255,0.05);
  --bg-recessed: rgba(0,0,0,0.18);

  /* Borders */
  --border-subtle: rgba(255,255,255,0.05);
  --border-default: rgba(255,255,255,0.1);
  --border-medium: rgba(255,255,255,0.2);
  --border-strong: rgba(255,255,255,0.3);

  /* Text */
  --text-primary: #fff;
  --text-secondary: #c4c3cc;
  --text-tertiary: #9998a8;
  --text-muted: #7a7a8c;
  --text-faint: #6f6f82;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #28282f;
  min-height: 100vh;
  color: #eaeaf0;
  line-height: 1.6;
}

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 16px;
  margin-bottom: 16px;
}

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

h1 {
  font-family: 'Raleway', sans-serif;
  font-size: 1.6rem;
  background: none;
  -webkit-text-fill-color: unset;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}
.logo-light { font-weight: 200; color: #c8c8d8; letter-spacing: 0.06em; }
.logo-bold  { font-weight: 700; color: var(--color-primary); letter-spacing: 0.08em; }

.drop-zone {
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 40px 32px;
  text-align: center;
  transition: all 0.3s ease;
  background: rgba(255,255,255,0.02);
}

.drop-zone.compact {
  padding: 10px 20px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  border-style: solid;
  border-color: rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}

.drop-zone.compact p {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.drop-zone.compact .btn {
  padding: 6px 14px;
  font-size: 12px;
}

.drop-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.08);
}

.drop-zone p { color: var(--text-secondary); margin-bottom: 16px; font-size: 14px; }

.intro-section {
  max-width: 520px;
  margin: 8px auto 24px;
  text-align: center;
  animation: fadeIn 0.5s ease forwards;
}

.intro-headline {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.intro-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.intro-features {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.intro-features li {
  font-size: 14px;
  color: var(--text-secondary);
}

.intro-features li::before {
  content: "✦";
  margin-right: 8px;
  color: var(--color-primary);
  font-size: 11px;
  vertical-align: middle;
}

.btn {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.25);
}

input[type="file"] { display: none; }

/* Results Layout */
.results {
  display: none;
}

.results.visible {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto;
  gap: 16px;
}

@media (max-width: 1100px) {
  .results.visible {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 16px;
}

.panel-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-header .icon { font-size: 0.9rem; }

/* Score Panel - Left sidebar */
.score-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Issues Panel - Full width below */
.issues-solutions-panel {
  grid-column: 1 / -1;
}

.analysis-filename {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 6px 8px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-display {
  text-align: center;
  padding: 20px 16px;
  background: var(--bg-elevated);
  border-radius: 8px;
}

.score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  position: relative;
  margin: 0 auto 12px;
}

.score-circle::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, var(--score-color), var(--score-color-dark));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.score-circle.good { --score-color: var(--color-success-light); --score-color-dark: var(--color-success); }
.score-circle.medium { --score-color: var(--color-warning-light); --score-color-dark: var(--color-warning); }
.score-circle.poor { --score-color: var(--color-error-light); --score-color-dark: var(--color-error); }

.score-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 400;
}

.score-info h3 {
  font-size: 1.05rem;
  margin-bottom: 2px;
  color: var(--text-primary);
  font-weight: 600;
}

.score-subtext {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Metrics in score panel */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 13px 10px;
  text-align: center;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
  font-weight: 500;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-value.good { color: var(--color-success-light); }
.metric-value.warning { color: var(--color-warning-light); }
.metric-value.danger { color: var(--color-error-light); }

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Preview Panel */
.preview-panel {
  display: flex;
  flex-direction: column;
}

.preview-container {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.canvas-wrap {
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 400px;
}

.canvas-wrap:active {
  cursor: grabbing;
}

.canvas-wrap.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  border-radius: 0;
  padding: 40px;
  background: #0a0a12;
}

.canvas-wrap.fullscreen canvas {
  max-width: 100%;
  max-height: 100%;
}

canvas { display: block; }

/* View Tabs */
.view-controls {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.zoom-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}

.zoom-btn,
.fullscreen-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.zoom-btn:hover,
.fullscreen-btn:hover {
  background: rgba(102, 126, 234, 0.3);
  border-color: var(--color-primary);
}

.zoom-btn {
  width: 36px;
  height: 36px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-level {
  color: var(--text-tertiary);
  font-size: 13px;
  min-width: 50px;
  text-align: center;
}

.fullscreen-btn {
  padding: 8px 16px;
  font-size: 13px;
}

.close-fullscreen {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  display: none;
}

.canvas-wrap.fullscreen + .close-fullscreen,
.close-fullscreen.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-hint {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
}

/* Visualizer Controls */
.visualizer-controls {
  background: var(--bg-recessed);
  border-radius: 10px;
  padding: 16px;
  margin-top: 12px;
}

.viz-playback {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.viz-btn {
  background: rgba(102, 126, 234, 0.3);
  border: 1px solid var(--color-primary);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.viz-btn:hover {
  background: rgba(102, 126, 234, 0.5);
}

.viz-btn.playing {
  background: rgba(74, 222, 128, 0.3);
  border-color: var(--color-success-light);
}

.viz-progress-wrap {
  flex: 1;
  position: relative;
  height: 24px;
}

.viz-progress {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  right: 0;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.viz-progress-bar {
  height: 100%;
  background: rgba(255, 255, 255, 0.4); /* Semi-transparent overlay */
  width: 0%;
  transition: width 0.1s linear;
  position: relative;
  z-index: 2;
  mix-blend-mode: overlay;
}

.viz-progress-segments {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  z-index: 1;
}

.viz-progress-segment {
  height: 100%;
  flex-shrink: 0;
}

.viz-color-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.viz-color-marker {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: rgba(255,255,255,0.6);
  border-radius: 1px;
}

.viz-scrubber {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.viz-time {
  color: var(--text-tertiary);
  font-size: 12px;
  min-width: 90px;
  text-align: right;
  font-family: monospace;
}

.viz-options {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.viz-options label,
.viz-background label {
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.viz-options select,
.viz-background select {
  background: #1a1a2e;
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
}

.viz-options select option,
.viz-background select option,
.thread-picker-brand option {
  background: #1a1a2e;
  color: #fff;
}

.viz-stitch-count {
  color: var(--color-success-light);
  font-size: 13px;
  font-family: monospace;
  margin-left: auto;
}

.viz-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.viz-color-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  padding: 8px 12px;
  border-radius: 6px;
}

.viz-color-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viz-color-thread {
  color: var(--text-muted);
  font-size: 12px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viz-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.viz-color-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

/* Thread Picker Modal */
.thread-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.thread-picker-overlay.active {
  opacity: 1;
  visibility: visible;
}

.thread-picker {
  background: #1a1a2e;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  width: 520px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.thread-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.thread-picker-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.thread-picker-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.thread-picker-close:hover {
  color: #fff;
}

.thread-picker-controls {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}

.thread-picker-search,
.thread-picker-brand {
  background: #1a1a2e;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
}

.thread-picker-search {
  flex: 1;
  min-width: 150px;
}

.thread-picker-brand {
  cursor: pointer;
}

.thread-picker-search::placeholder {
  color: var(--text-faint);
}

.thread-picker-sort {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 6px;
}

.thread-picker-sort button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.thread-picker-sort button.active {
  background: rgba(102, 126, 234, 0.2);
  color: #fff;
}

.thread-picker-swatches {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  align-content: start;
}

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

.thread-swatch:hover {
  background: rgba(255,255,255,0.05);
}

.thread-swatch.selected {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.5);
}

.thread-swatch-color {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.thread-swatch-id {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
}

.thread-swatch-brand {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Brand-specific colors */
.thread-swatch[data-brand="brothread"] .thread-swatch-brand {
  color: var(--color-success-light);
}

.thread-swatch[data-brand="isacord"] .thread-swatch-brand {
  color: #60a5fa;
}

.thread-swatch[data-brand="madeira"] .thread-swatch-brand {
  color: #f472b6;
}

.thread-swatch[data-brand="sulky"] .thread-swatch-brand {
  color: var(--color-warning-light);
}

.thread-swatch-name {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-picker-preview {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 16px;
  align-items: center;
}

.thread-preview-swatch {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 2px solid var(--border-medium);
  flex-shrink: 0;
}

.thread-preview-info {
  flex: 1;
}

.thread-preview-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.thread-preview-details {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.thread-picker-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-elevated);
}

.thread-picker-custom label {
  color: var(--text-muted);
  font-size: 12px;
}

.thread-picker-custom input[type="text"] {
  width: 80px;
  background: var(--bg-recessed);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 6px 8px;
  color: #fff;
  font-size: 12px;
  font-family: monospace;
}

.thread-picker-custom input[type="color"] {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.thread-picker-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.thread-picker-btn {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.thread-picker-btn-cancel {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
}

.thread-picker-btn-cancel:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.thread-picker-btn-apply {
  background: var(--gradient-primary);
  border: none;
  color: #fff;
}

.thread-picker-btn-apply:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.thread-family-header {
  grid-column: 1 / -1;
  font-size: 12px;
  text-transform: uppercase;
  color: #444;
  letter-spacing: 0.5px;
  padding: 8px 0 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-top: 8px;
}

.thread-family-header:first-child {
  margin-top: 0;
}

.viz-background {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.viz-background input[type="color"] {
  width: 32px;
  height: 24px;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

/* Export UI */
.viz-export {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-default);
}

.viz-export-title {
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.viz-export-formats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.viz-format-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  position: relative;
  background: var(--bg-elevated);
  border: 2px solid var(--border-default);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.viz-format-option:hover {
  background: var(--bg-recessed);
  border-color: var(--border-medium);
}

.viz-format-option.selected {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
}

.viz-format-option.unsupported {
  opacity: 0.65;
  cursor: not-allowed;
  border-color: rgba(245, 158, 11, 0.3);
}

.viz-format-option.unsupported:hover {
  background: var(--bg-elevated);
  border-color: rgba(245, 158, 11, 0.3);
}

.viz-format-option.unsupported .viz-format-name {
  color: var(--text-muted);
}

.viz-format-option.unsupported .viz-format-desc {
  color: var(--color-warning-light);
  font-weight: 500;
}

.viz-format-radio {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.viz-format-option.selected .viz-format-radio {
  border-color: #10b981;
}

.viz-format-option.selected .viz-format-radio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
}

.viz-format-info-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.viz-format-label {
  flex: 1;
}

.viz-format-name {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.viz-format-desc {
  color: var(--text-tertiary);
  font-size: 12px;
}

.viz-format-info-btn {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: help;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.viz-format-info-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}

.viz-format-tooltip {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  padding: 12px;
  background: #1a1a2e;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  width: 280px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 1000;
  pointer-events: none;
}

.viz-format-info-btn:hover + .viz-format-tooltip {
  opacity: 1;
  visibility: visible;
}

.viz-tooltip-title {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.viz-tooltip-text {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.viz-tooltip-specs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-default);
}

.viz-tooltip-spec {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.viz-tooltip-spec-label {
  color: var(--text-tertiary);
}

.viz-tooltip-spec-value {
  color: var(--text-primary);
  font-weight: 500;
}

.viz-btn-export {
  background: var(--gradient-export);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  transition: all 0.2s;
}

.viz-btn-export:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.viz-export-progress {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: 6px;
}

.viz-progress-bar-export {
  height: 8px;
  background: var(--bg-recessed);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
  position: relative;
}

.viz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  width: 0%;
  transition: width 0.3s;
}

.viz-progress-fill.encoding {
  background: linear-gradient(90deg, #10b981, #059669, #10b981);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

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

.viz-export-progress-text {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.viz-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Export Recording Overlay */
.export-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 8px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.export-overlay.active {
  opacity: 1;
  visibility: visible;
}

.export-overlay-icon {
  font-size: 48px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.export-overlay-title {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
}

.export-overlay-status {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  max-width: 280px;
}

.export-overlay-progress {
  width: 200px;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
}

.export-overlay-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  width: 0%;
  transition: width 0.2s;
}

.export-overlay-cancel {
  margin-top: 8px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: var(--color-error-light);
  padding: 8px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.export-overlay-cancel:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: var(--color-error-light);
}

/* Disabled state for visualizer controls during export */
.visualizer-controls.export-active {
  pointer-events: none;
  opacity: 0.5;
}

.visualizer-controls.export-active .viz-playback,
.visualizer-controls.export-active .viz-options,
.visualizer-controls.export-active .viz-colors,
.visualizer-controls.export-active .viz-background {
  filter: blur(1px);
}

/* Keep export section interactive but show different state */
.visualizer-controls.export-active .viz-export {
  pointer-events: auto;
  opacity: 1;
  filter: none;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

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

.view-btn.active {
  background: rgba(102, 126, 234, 0.2);
  color: var(--text-primary);
}

.view-btn[data-view="problems"] {
  color: var(--color-warning-light);
}

.view-btn[data-view="problems"].active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning-light);
}

.view-btn[data-view="visualize"] {
  color: var(--color-success-light);
}

.view-btn[data-view="visualize"].active {
  background: rgba(74, 222, 128, 0.15);
  color: var(--color-success-light);
}

/* Problems Legend (absolute panel, left of canvas inside canvas-wrap) */
.problems-legend {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  min-width: 145px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  z-index: 1;
}

.pl-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.pl-section-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

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

.pl-swatch {
  flex-shrink: 0;
}

.pl-rect {
  width: 16px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.pl-circle {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

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

.pl-text {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* View info bar — always visible between tab strip and canvas */
.view-info-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 8px;
  padding: 8px 16px;
  background: var(--bg-recessed);
  border-radius: 8px;
  min-height: 38px;
}

.view-description {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Problems toggles (shown inside view-info-bar on the Problems tab) */
.problems-toggles {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
}

.problems-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  user-select: none;
  transition: color 0.2s;
}

.problems-toggle:hover {
  color: var(--text-primary);
}

.problems-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--color-warning);
  flex-shrink: 0;
}

/* Combined Issues & Solutions */
.issues-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.issue-solution-card {
  background: var(--bg-elevated);
  border-radius: 8px;
  overflow: hidden;
  border-left: 3px solid;
  display: flex;
  flex-direction: row;
}

@media (max-width: 800px) {
  .issue-solution-card {
    flex-direction: column;
  }
  .solution-section {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }
}

.issue-solution-card.error { border-color: var(--color-error); }
.issue-solution-card.warning { border-color: var(--color-warning); }
.issue-solution-card.info { border-color: var(--color-info); }

.issue-section {
  padding: 16px 18px;
  flex: 1;
  min-width: 0;
}

.issue-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.issue-section-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.issue-solution-card.error .issue-section-icon { background: rgba(239, 68, 68, 0.2); color: var(--color-error-light); }
.issue-solution-card.warning .issue-section-icon { background: rgba(245, 158, 11, 0.2); color: var(--color-warning-light); }
.issue-solution-card.info .issue-section-icon { background: rgba(59, 130, 246, 0.2); color: var(--color-info-light); }

.issue-section-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.issue-section-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.issue-section-impact {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.issue-stitch-indices {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-family: monospace;
  margin-top: 6px;
  padding: 4px 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  word-break: break-word;
}

.solution-section {
  padding: 16px 18px;
  background: rgba(34, 197, 94, 0.05);
  border-left: 1px solid rgba(255,255,255,0.05);
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.solution-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--color-success-light);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.solution-header-icon {
  font-size: 0.85rem;
}

.solution-action {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.solution-benefit {
  margin-top: 8px;
  color: var(--color-success-light);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.no-issues-card {
  text-align: center;
  padding: 32px;
  background: rgba(34, 197, 94, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.15);
}

.no-issues-card .icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.no-issues-card .message {
  color: var(--color-success-light);
  font-size: 1rem;
  font-weight: 600;
}

.no-issues-card .sub-message {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.results.visible .panel {
  animation: fadeIn 0.5s ease forwards;
}

.results.visible .panel:nth-child(2) { animation-delay: 0.1s; }
.results.visible .panel:nth-child(3) { animation-delay: 0.2s; }
.results.visible .panel:nth-child(4) { animation-delay: 0.3s; }
.results.visible .panel:nth-child(5) { animation-delay: 0.4s; }

/* ============================================
   Feedback Button & Modal
   ============================================ */

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

.feedback-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--color-primary);
  color: var(--text-primary);
}

/* Feedback button wrapper for tooltip */
.feedback-btn-wrap {
  position: relative;
}

.feedback-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.feedback-btn:disabled:hover {
  background: transparent;
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

/* Custom tooltip for disabled state */
.feedback-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  padding: 8px 12px;
  background: #1a1a2e;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.feedback-btn:disabled:hover + .feedback-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Hide tooltip when button is enabled */
.feedback-btn:not(:disabled) + .feedback-tooltip {
  display: none;
}

/* Donate Button */
.donate-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.donate-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-primary);
  color: var(--text-primary);
}

/* Feedback Modal Overlay */
.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.feedback-overlay.active {
  opacity: 1;
  visibility: visible;
}

.feedback-modal {
  background: #1a1a2e;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.feedback-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.feedback-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.feedback-close:hover {
  color: #fff;
}

.feedback-body {
  padding: 20px;
}

.feedback-label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}

.feedback-textarea {
  width: 100%;
  background: var(--bg-recessed);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.feedback-textarea::placeholder {
  color: var(--text-faint);
}

.feedback-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.feedback-btn-cancel {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-btn-cancel:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.feedback-btn-submit {
  background: var(--gradient-primary);
  border: none;
  color: #fff;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.feedback-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Feedback Success State */
.feedback-success {
  padding: 40px 20px;
  text-align: center;
}

.feedback-success-icon {
  width: 60px;
  height: 60px;
  background: rgba(34, 197, 94, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  color: var(--color-success-light);
}

.feedback-success-message {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.feedback-btn-done {
  background: var(--gradient-primary);
  border: none;
  color: #fff;
  padding: 10px 32px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-btn-done:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ── Footer ─────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  padding: 14px 0 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--text-secondary);
}

.footer-link:hover .footer-logo {
  opacity: 1;
}

.footer-logo {
  width: 26px;
  height: 26px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  border-radius: 50%;
}

.footer-text {
  font-size: 0.8rem;
  letter-spacing: 0.015em;
}

.footer-text strong {
  color: var(--text-secondary);
  font-weight: 500;
}
