/* Reset & base layout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", system-ui, sans-serif;
  font-weight: 300;
  background: #f5f5f7;
  color: #111827;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Page structure */

.page-header {
  padding: 32px 16px 8px;
  max-width: 1120px;
  margin: 0 auto;
  color: #166534;
}

.page-title {
  margin: 0 0 6px;
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0;
  max-width: 720px;
  color: #6b7280;
  font-size: 13px;
}

.page-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.page-footer {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  padding: 10px 16px 18px;
  margin-top: 16px;
  background: rgba(245, 245, 247, 0.95);
  backdrop-filter: blur(10px);
}

.footer-text {
  margin: 0;
  text-align: center;
  font-size: 13px;
  text-transform: uppercase;
  color: #166534;
}

/* Cards / sections */

.card {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  padding: 18px 20px 20px;
  margin-top: 14px;
  box-shadow:
    0 12px 30px rgba(15, 23, 42, 0.03),
    0 0 0 1px rgba(255, 255, 255, 0.9);
}

.section-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  border-radius: 999px;
  background: #16a34a;
}

.section-description {
  margin: 0 0 10px;
  font-size: 13px;
  color: #4b5563;
}

.helper-text {
  font-size: 12px;
  color: #6b7280;
}

/* Fields and buttons */

.field {
  margin-bottom: 10px;
}

.field-label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: #111827;
}

.field-label-small {
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
  color: #4b5563;
}

input[type="file"],
input[type="number"] {
  display: block;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: #f9fafb;
  color: #111827;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

input[type="file"]:hover,
input[type="number"]:hover {
  background: #ffffff;
}

input[type="file"]:focus,
input[type="number"]:focus {
  border-color: #16a34a;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.18);
}

/* Range input styling */
.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  outline: none;
  margin: 8px 0;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #166534;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(22, 101, 52, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(22, 101, 52, 0.4);
}

.range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #166534;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(22, 101, 52, 0.3);
}

.range-value {
  display: inline-block;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #166534;
  font-weight: 500;
  min-width: 50px;
}

.param-field {
  padding: 8px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.param-field:last-of-type {
  border-bottom: none;
}

#upload-section .field {
  margin-bottom: 6px;
}

/* Primary button */

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 7px 18px;
  background: #166534;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.15s ease;
  box-shadow: 0 12px 24px rgba(22, 101, 52, 0.25);
}

.primary-btn:hover:not(:disabled) {
  background: #14532d;
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(22, 101, 52, 0.3);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(22, 101, 52, 0.25);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

/* Configuration section */

.config-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.config-group {
  flex: 1 1 200px;
  min-width: 180px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
}

.radio-label input[type="radio"] {
  accent-color: #16a34a;
  width: 14px;
  height: 14px;
}

.radio-text {
  transition: color 0.15s ease;
}

.radio-label:hover .radio-text {
  color: #166534;
}

.radio-label input[type="radio"]:checked + .radio-text {
  color: #166534;
  font-weight: 400;
}

/* Canvas and selection section */

.canvas-wrapper {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #f9fafb;
}

#selection-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

#selection-canvas:active {
  cursor: crosshair;
}

.selection-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.selection-info {
  margin: 0;
  font-size: 12px;
  color: #374151;
}

/* Hamming process section */

.hamming-content {
  margin-top: 10px;
}

.hamming-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.hamming-block:first-of-type {
  border-top: none;
  padding-top: 0;
}

.hamming-subtitle {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 400;
  color: #166534;
  letter-spacing: -0.01em;
}

/* Matrices and equations */

.matrix-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.matrix-group {
  flex: 1 1 220px;
  min-width: 0;
}

.matrix-label {
  font-size: 11px;
  color: #4b5563;
  margin-bottom: 4px;
  display: inline-block;
}

.matrix-container {
  display: inline-block;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #f5fdf7;
  padding: 4px 6px;
}

.matrix-table {
  border-collapse: collapse;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  color: #111827;
}

.matrix-table td {
  padding: 1px 7px;
  text-align: center;
}

/* Equations & bits */

.equation-line {
  margin: 4px 0;
  font-size: 12px;
  color: #111827;
}

.bit-sequence,
.bit-highlight,
.bit-error,
.bit-warning {
  display: inline-block;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}

.bit-sequence {
  background: #ecfdf5;
  color: #064e3b;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.bit-highlight {
  background: #e0f2f1;
  color: #115e59;
  border: 1px solid rgba(45, 212, 191, 0.55);
}

.bit-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.bit-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Summary list */

.summary-list {
  list-style: none;
  padding-left: 0;
  margin: 4px 0 0;
  font-size: 12px;
  color: #374151;
}

.summary-list li {
  margin: 2px 0;
}

.summary-value {
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  margin-left: 6px;
  color: #166534;
}

/* Inspector layout */

.inspector-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.inspector-col {
  flex: 1 1 220px;
  min-width: 0;
}

/* Image visualization section */

.canvas-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.canvas-column {
  flex: 1 1 260px;
  min-width: 0;
}

.canvas-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 400;
  color: #166534;
}

.canvas-frame {
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #f9fafb;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.canvas-frame canvas {
  display: block;
  max-width: 100%;
  max-height: 260px;
  width: auto;
  height: auto;
}

/* Performance Analysis - Horizontal Layout */

.perf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.perf-item {
  flex: 1 1 140px;
  min-width: 120px;
  background: #f5fdf7;
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.perf-label {
  font-size: 11px;
  color: #4b5563;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.perf-value {
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 18px;
  font-weight: 500;
  color: #166534;
}

.perf-value.good {
  color: #047857;
}

.perf-value.warn {
  color: #b45309;
}

.perf-value.bad {
  color: #b91c1c;
}

/* Real data section - 4 blocks grid */

.data-grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 12px;
}

.data-card {
  background: #f9fafb;
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.data-card-title {
  font-size: 12px;
  font-weight: 500;
  color: #166534;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.data-card-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 12px;
  border-radius: 999px;
  background: #16a34a;
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.data-row:last-child {
  border-bottom: none;
}

.data-label {
  font-size: 12px;
  color: #4b5563;
}

.data-value {
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  color: #111827;
}

.data-value.good {
  color: #047857;
}

.data-value.warn {
  color: #b45309;
}

.data-value.bad {
  color: #b91c1c;
}

/* Progress bar */

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-bar.good {
  background: linear-gradient(90deg, #10b981, #047857);
}

.progress-bar.warn {
  background: linear-gradient(90deg, #f59e0b, #b45309);
}

.progress-bar.bad {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
}

/* Section 7: All Schemes Comparison */

.scheme-comparison-row {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f9fafb;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.scheme-comparison-row:first-of-type {
  margin-top: 12px;
}

.scheme-row-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.scheme-row-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scheme-row-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  border-radius: 999px;
  background: #16a34a;
}

.scheme-stats-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scheme-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
}

.scheme-stat-label {
  color: #6b7280;
}

.scheme-stat-value {
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-weight: 500;
  color: #166534;
}

.scheme-stat-value.good {
  color: #047857;
}

.scheme-stat-value.warn {
  color: #b45309;
}

.scheme-stat-value.bad {
  color: #b91c1c;
}

.scheme-canvas-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.scheme-canvas-item {
  flex: 1 1 280px;
  min-width: 200px;
}

.scheme-canvas-label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: #4b5563;
  margin-bottom: 8px;
}

.scheme-canvas-item canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Responsive for Section 7 */
@media (max-width: 768px) {
  .scheme-row-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .scheme-canvas-pair {
    flex-direction: column;
    gap: 16px;
  }

  .scheme-canvas-item {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .scheme-stats-inline {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .scheme-stat-chip {
    padding: 3px 8px;
    font-size: 10px;
  }

  .scheme-comparison-row {
    padding: 12px 14px;
  }
}

/* Responsive tweaks */

@media (max-width: 768px) {
  .page-header {
    padding-top: 20px;
  }

  .page-title {
    font-size: 21px;
  }

  .page-main {
    padding: 0 12px 20px;
  }

  .card {
    padding: 14px 14px 16px;
    border-radius: 16px;
  }

  .selection-info-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .canvas-row {
    flex-direction: column;
  }

  .config-row {
    flex-direction: column;
  }

  .data-grid-4 {
    grid-template-columns: 1fr;
  }

  .perf-row {
    flex-direction: column;
  }

  .perf-item {
    flex: 1 1 100%;
  }

  .scheme-row-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .scheme-canvas-pair {
    flex-direction: column;
  }

  .scheme-canvas-item {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .scheme-stats-inline {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .perf-row {
    gap: 8px;
  }

  .perf-item {
    padding: 10px 12px;
  }

  .perf-value {
    font-size: 16px;
  }

  .data-card {
    padding: 12px 14px;
  }

  .data-card-title {
    font-size: 11px;
  }

  .data-row {
    padding: 5px 0;
  }

  .data-label {
    font-size: 11px;
  }

  .data-value {
    font-size: 12px;
  }

  .scheme-stat-chip {
    padding: 3px 8px;
    font-size: 10px;
  }
}