/* 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; /* neutral macOS-like gray */
  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: 640px;
  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; /* dark green accent for USNs */
}

/* 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; /* darker, solid green accent */
}

.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;
}

/* File + number inputs: subtle, native-like */
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; /* gentle green focus */
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.18);
}

/* Slightly tighter for the upload section */
#upload-section .field {
  margin-bottom: 6px;
}

/* Primary button */

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 7px 18px;
  background: #166534; /* dark green button */
  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;
}

/* Canvas and selection section */

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

/* Fixed visual size; internal size handled in JS */
/* Selection canvas: responsive, keeps aspect ratio */
#selection-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Output canvases: same idea */
/* Default: show crosshair when hovering the selection canvas */
#selection-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

/* Keep crosshair while dragging as well */
#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; /* dark green titles */
  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; /* very light green-tinted background */
  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 {
  display: inline-block;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ecfdf5; /* soft green chip */
  color: #064e3b; /* dark green text */
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.bit-highlight {
  display: inline-block;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e0f2f1;
  color: #115e59;
  border: 1px solid rgba(45, 212, 191, 0.55);
}

/* 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; /* dark green for numbers */
}

/* 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);
}

/* Fixed visual size for output canvases */
.canvas-frame canvas {
  display: block;
  max-width: 100%;
  max-height: 260px;
  width: auto;
  height: auto;
}

/* Utility */

.hidden {
  display: none;
}

/* 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;
  }
}
