:root {
  color-scheme: dark;
  --bg: #10100e;
  --panel: #e9e4d7;
  --ink: #151411;
  --muted: #6d675b;
  --line: #2f312b;
  --accent: #e6502e;
  --accent-2: #2c8f7b;
  --dark-panel: #181914;
  --dark-ink: #f2eee4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--dark-ink);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.workspace {
  width: min(1120px, 100%);
  min-width: 0;
}

.header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  font: 700 12px/1.1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0;
  color: var(--accent);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 8vw, 92px);
  line-height: 0.9;
  letter-spacing: 0;
}

.status {
  min-width: 104px;
  border: 1px solid #4a4c43;
  color: #d9d1bf;
  padding: 8px 12px;
  text-align: center;
  font: 800 13px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.status.ready {
  border-color: var(--accent-2);
  color: #85d4c6;
}

.status.down {
  border-color: var(--accent);
  color: #ffb29f;
}

.grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
  align-items: stretch;
}

.upload-panel,
.result-panel {
  border: 1px solid var(--line);
}

.upload-panel {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  gap: 12px;
  padding: 12px;
  background: var(--dark-panel);
}

.dropzone {
  display: grid;
  gap: 6px;
  align-content: center;
  min-height: 112px;
  border: 1px dashed #68685f;
  padding: 18px;
  cursor: pointer;
  background: #202119;
}

.dropzone.dragging {
  border-color: var(--accent-2);
  background: #17241f;
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  color: var(--dark-ink);
  font-size: 24px;
  line-height: 1;
}

.drop-meta,
.fineprint,
.message {
  color: #aaa391;
  font: 500 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.training-consent {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: #d9d1bf;
  font: 700 12px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  cursor: pointer;
}

.training-consent input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-2);
  flex: 0 0 auto;
}

.training-consent span {
  overflow-wrap: anywhere;
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
  overflow: hidden;
  background: #090a08;
}

.crop-overlay {
  position: absolute;
  display: none;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.22);
  cursor: move;
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
}

.crop-overlay.visible {
  display: block;
}

.crop-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent);
  background: var(--panel);
  touch-action: none;
  z-index: 2;
}

.crop-handle-nw {
  left: -11px;
  top: -11px;
  cursor: nwse-resize;
}

.crop-handle-ne {
  right: -11px;
  top: -11px;
  cursor: nesw-resize;
}

.crop-handle-sw {
  left: -11px;
  bottom: -11px;
  cursor: nesw-resize;
}

.crop-handle-se {
  right: -11px;
  bottom: -11px;
  cursor: nwse-resize;
}

.preview-frame img {
  display: none;
  width: 100%;
  height: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.preview-frame.has-image img {
  display: block;
}

.empty-preview {
  color: #5d5e55;
  font: 700 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.preview-frame.has-image .empty-preview {
  display: none;
}

button {
  min-height: 52px;
  border: 0;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: 800 15px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

button:disabled {
  cursor: not-allowed;
  background: #4b4c44;
  color: #979283;
}

.payment-button {
  min-height: 34px;
  min-width: 124px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  background: transparent;
  color: #ffb29f;
  font-size: 13px;
}

.payment-button:disabled {
  border-color: #4b4c44;
  background: transparent;
}

.result-panel {
  display: grid;
  grid-template-rows: auto auto auto auto;
  min-width: 0;
  min-height: 520px;
  overflow: hidden;
  padding: clamp(18px, 4vw, 44px);
  background: var(--panel);
  color: var(--ink);
}

.result-panel.is-rating {
  box-shadow: inset 0 0 0 2px rgba(230, 80, 46, 0.28);
}

.result-panel.is-rating .message::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  background: var(--accent);
  animation: rating-pulse 0.8s ease-in-out infinite alternate;
  vertical-align: 1px;
}

@keyframes rating-pulse {
  from {
    opacity: 0.35;
  }

  to {
    opacity: 1;
  }
}

.score-block {
  min-width: 0;
}

.label {
  margin: 0 0 10px;
  color: var(--muted);
  font: 800 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.score {
  max-width: 100%;
  white-space: nowrap;
  font-size: clamp(88px, 12vw, 176px);
  line-height: 0.86;
  letter-spacing: 0;
  font-weight: 700;
  margin-bottom: clamp(26px, 3vw, 44px);
}

.metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-top: 1px solid #c8c0ae;
  border-bottom: 1px solid #c8c0ae;
}

.metrics div {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px 14px;
}

.metrics div + div {
  border-left: 1px solid #c8c0ae;
}

.metrics div:first-child strong {
  display: grid;
  gap: 5px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: clamp(24px, 2.7vw, 33px);
  line-height: 1;
}

.population-rarity,
.population-percentile {
  display: block;
}

.population-rarity {
  line-height: 0.92;
}

.population-percentile {
  color: #5d584e;
  font: 850 13px/1.15 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metrics > div > span {
  color: var(--muted);
  font: 850 13px/1.05 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.metrics strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.message {
  color: #5d584e;
  font: 650 15px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  min-height: 44px;
  margin: 18px 0 0;
}

.factor-guide {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 2px solid #b9ad98;
}

.factor-guide[hidden] {
  display: none;
}

.factor-guide-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #cec3ae;
}

.factor-guide-head span {
  color: var(--muted);
  font: 800 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.factor-guide-head strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.factor-guide ol {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid #d1c7b4;
  background: #d1c7b4;
}

.factor-guide li {
  display: grid;
  grid-template-columns: minmax(94px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  padding: 8px 11px;
  background: #eee8d9;
  color: #463f35;
}

.factor-guide li strong {
  color: #211f1a;
  font: 800 12px/1.25 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.factor-guide li span {
  min-width: 0;
  font: 650 13px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.analysis-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px 0 0;
  border-top: 2px solid #b9ad98;
}

.analysis-panel[hidden] {
  display: none;
}

.analysis-section > span {
  color: var(--muted);
  font: 800 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.report-button {
  justify-self: start;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid #9d917c;
  background: transparent;
  color: #343027;
  font-size: 11px;
  letter-spacing: 0;
}

.report-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.report-button[hidden] {
  display: none;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.analysis-grid.strengths-wide .analysis-section-good {
  grid-column: 1 / -1;
}

.analysis-section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 9px;
  padding-top: 2px;
}

.analysis-section[hidden] {
  display: none;
}

.analysis-summary-wrap {
  gap: 7px;
  padding: 2px 0 4px;
}

.analysis-summary {
  margin: 0;
  padding: 12px 13px;
  border-left: 3px solid var(--accent);
  background: #f7f1e3;
  color: #211f1a;
  font: 750 15px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.analysis-panel ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.analysis-panel li {
  position: relative;
  min-height: 34px;
  padding: 9px 10px 9px 28px;
  border: 1px solid #d1c7b4;
  background: #eee8d9;
  color: #463f35;
  font: 650 13px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
}

.analysis-panel li.primary {
  border-color: #b5a68d;
  background: #f7f1e3;
  color: #211f1a;
}

.analysis-panel li::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 15px;
  width: 7px;
  height: 7px;
  background: var(--accent-2);
}

.analysis-section-bad li::before {
  background: var(--accent);
}

.analysis-section-note li::before {
  background: #8d846f;
}

.analysis-tips {
  padding-top: 4px;
  border-top: 1px solid #cec3ae;
}

.analysis-tips li {
  background: transparent;
  border-color: #cec3ae;
  color: #5a5348;
  font-weight: 600;
}

.post-score-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #cbbfa9;
  background: #f3ecdc;
}

.post-score-cta[hidden] {
  display: none;
}

.post-score-cta div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.post-score-cta span {
  color: var(--accent-2);
  font: 800 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.post-score-cta strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.post-score-cta p {
  margin: 0;
  color: #5d584e;
  font: 650 12px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
}

.post-score-cta .payment-button {
  min-height: 42px;
  min-width: 142px;
  color: var(--accent);
  background: transparent;
}

.post-score-cta .payment-button:hover:not(:disabled) {
  background: var(--accent);
  color: white;
}

.fineprint {
  max-width: 680px;
  margin: 14px 0 0;
}

@media (max-width: 780px) {
  .shell {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 10px 10px 18px;
    place-items: start center;
  }

  .workspace,
  .header,
  .grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
    margin-bottom: 10px;
  }

  .header > div:first-child {
    min-width: 0;
  }

  .eyebrow {
    font-size: 10px;
  }

  h1 {
    font-size: 46px;
  }

  .status {
    min-width: 0;
    width: 100%;
    padding: 7px 8px;
    font-size: 11px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    justify-self: stretch;
    gap: 6px;
    overflow: hidden;
  }

  .payment-button {
    min-height: 30px;
    min-width: 0;
    width: 100%;
    padding: 0 8px;
    font-size: 11px;
  }

  .payment-button,
  .status {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .upload-panel {
    grid-template-rows: auto minmax(220px, auto) auto;
    gap: 10px;
    padding: 10px;
  }

  .dropzone {
    min-height: 70px;
    padding: 12px 14px;
  }

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

  .drop-meta,
  .fineprint,
  .message {
    font-size: 12px;
  }

  .preview-frame {
    min-height: 220px;
  }

  .preview-frame img {
    max-height: 50vh;
  }

  button {
    min-height: 48px;
  }

  .result-panel {
    min-height: 0;
    grid-template-rows: auto auto auto auto;
    padding: 18px;
    scroll-margin-top: 10px;
  }

  .label {
    margin-bottom: 8px;
  }

  .score {
    font-size: clamp(80px, 24vw, 96px);
    margin-bottom: 20px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metrics div {
    padding: 12px 10px;
  }

  .metrics div + div {
    border-left: 0;
  }

  .metrics div:nth-child(n + 2) {
    border-top: 1px solid #c8c0ae;
  }

  .metrics strong {
    gap: 6px;
    font-size: 24px;
  }

  .metrics div:first-child strong {
    font-size: 24px;
  }

  .message {
    min-height: 0;
    margin-top: 14px;
    font-size: 14px;
  }

  .factor-guide {
    margin-top: 14px;
    padding-top: 14px;
  }

  .factor-guide-head {
    display: grid;
    gap: 8px;
  }

  .factor-guide-head strong {
    font-size: 22px;
  }

  .factor-guide li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .analysis-panel {
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .analysis-panel li {
    font-size: 12px;
  }

  .post-score-cta {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
    padding: 12px;
  }

  .post-score-cta strong {
    font-size: 22px;
  }

  .post-score-cta .payment-button {
    width: 100%;
  }

  .fineprint {
    margin-top: 10px;
    padding: 0 2px;
  }

}

@media (max-width: 380px) {
  h1 {
    font-size: 40px;
  }

  .metrics strong {
    font-size: 21px;
  }

  .metrics div:first-child strong {
    font-size: 21px;
  }
}
