:root {
  --bg: #0c1417;
  --panel: #14232a;
  --border: #233a42;
  --text: #eaf1f1;
  --muted: #879ba0;
  --source-a: #37c7b4;
  --source-b: #efb24c;
  --green: #3ecf8e;
  --amber: #efb24c;
  --red: #e5686b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.wrap {
  width: 100%;
  max-width: 560px;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 2rem;
  margin: 0 0 6px;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: #0c1417;
  background: var(--source-a);
  border-color: var(--source-a);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel.hidden {
  display: none;
}

.photo-area {
  display: flex;
  justify-content: center;
}

.photo-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0f11;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a0f11;
}

.source-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 8px;
  color: #0c1417;
}

.source-tag.source-A {
  background: var(--source-a);
}

.source-tag.source-B {
  background: var(--source-b);
}

.controls {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.15);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

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

.btn-primary {
  background: var(--source-a);
  color: #0c1417;
  border-color: var(--source-a);
}

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result.hidden {
  display: none;
}

.result-row {
  display: flex;
  gap: 12px;
}

.result-card {
  flex: 1;
  background: #0e1a1f;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-value {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 1.4rem;
}

.error-badge {
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  border: 1px solid var(--border);
}

.error-badge.good {
  background: rgba(62, 207, 142, 0.12);
  color: var(--green);
  border-color: var(--green);
}

.error-badge.mid {
  background: rgba(239, 178, 76, 0.12);
  color: var(--amber);
  border-color: var(--amber);
}

.error-badge.bad {
  background: rgba(229, 104, 107, 0.12);
  color: var(--red);
  border-color: var(--red);
}

.status {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  min-height: 1em;
}

.hidden {
  display: none !important;
}

/* ============ Upload view ============ */
.dropzone {
  display: block;
  cursor: pointer;
}

.upload-frame {
  border-style: dashed;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover .upload-frame,
.dropzone.dragging .upload-frame {
  border-color: var(--source-a);
  background: #0d1a1e;
}

.dropzone-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 20px;
}

.dz-plus {
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1;
  color: var(--source-a);
}

.dz-sub {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.8;
}

.upload-controls {
  align-items: center;
}

.source-select {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.source-select label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.source-select select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0e1a1f;
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
}

.upload-controls .btn {
  flex: 1;
}

.predicted-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  background: #0e1a1f;
  border: 1px solid var(--source-a);
  border-radius: 12px;
  padding: 20px;
}

.predicted-big-value {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 2.6rem;
  color: var(--source-a);
  line-height: 1;
}

.predicted-big-unit {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1rem;
  color: var(--muted);
}

.upload-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clip-note {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--amber);
  text-align: center;
}

.fold-spread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0e1a1f;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.fold-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fold-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}

.fold-idx {
  color: var(--muted);
  width: 22px;
  flex-shrink: 0;
}

.fold-track {
  flex: 1;
  height: 8px;
  background: #16262c;
  border-radius: 4px;
  overflow: hidden;
}

.fold-fill {
  display: block;
  height: 100%;
  background: var(--source-a);
  border-radius: 4px;
}

.fold-val {
  width: 44px;
  text-align: right;
  color: var(--text);
  flex-shrink: 0;
}
