:root {
  --ink: #1b1e1c;
  --ink-soft: #2d312e;
  --muted: #6b706c;
  --line: #cfd3ce;
  --paper: #f4f5f1;
  --panel: #ffffff;
  --acid: #cfff3f;
  --acid-soft: #efffc2;
  --blue: #2667c9;
  --blue-soft: #e9f0fd;
  --red: #d94b43;
  --red-soft: #fff0ee;
  --green-ink: #2f6e36;
  --shadow: 0 10px 24px rgba(27, 30, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
}

.app-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
  background: var(--ink);
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  font-size: 16px;
  font-weight: 780;
  text-decoration: none;
  letter-spacing: 0;
}

.brand-mark {
  width: 25px;
  height: 25px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
}

.brand-mark i {
  display: block;
  background: var(--acid);
}

.brand-mark i:last-child {
  background: transparent;
  border: 2px solid var(--acid);
}

.top-controls,
.stepper {
  display: flex;
  align-items: center;
}

.top-controls {
  gap: 10px;
}

.threshold-label {
  color: #d7dad7;
  font-size: 12px;
}

.stepper {
  height: 36px;
  overflow: hidden;
  border: 1px solid #4a504b;
  background: var(--ink-soft);
}

.stepper-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
}

.stepper-button:hover {
  background: #3a403b;
}

.stepper-button img {
  width: 15px;
  height: 15px;
  filter: invert(1);
}

.stepper-value {
  min-width: 54px;
  color: var(--acid);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: calc(100vh - 64px);
}

.comparison-column {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 42px) 32px;
}

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

.eyebrow,
.media-kicker,
.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.comparison-header h1,
.result-header h2,
.media-card-header h2 {
  margin: 3px 0 0;
  font-weight: 800;
  letter-spacing: 0;
}

.comparison-header h1 {
  font-size: 22px;
}

.result-header h2 {
  font-size: 20px;
}

.media-card-header h2 {
  font-size: 14px;
}

.section-copy {
  max-width: 560px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.button,
.link-button,
.preview-replace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  font-weight: 750;
  letter-spacing: 0;
}

.button {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 3px;
}

.button img,
.link-button img,
.preview-replace img,
.workspace-note img {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.button--primary {
  background: var(--blue);
  color: #fff;
}

.button--primary:hover:not(:disabled) {
  background: #1e54a6;
}

.button--primary:disabled {
  background: #aabbd9;
  color: #edf2fb;
}

.button--primary img {
  filter: brightness(0) invert(1);
}

.button--primary img.is-spinning {
  animation: spin-icon 900ms linear infinite;
}

.button--secondary {
  border: 1px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
}

.button--secondary:hover {
  background: #f0f2ed;
}

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

.media-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 0 2px 0 rgba(27, 30, 28, 0.02);
}

.media-card-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
}

.link-button {
  padding: 5px 0;
  background: transparent;
  color: var(--blue);
  font-size: 11px;
  white-space: nowrap;
}

.link-button:hover {
  color: #1e54a6;
}

.link-button img,
.preview-replace img {
  width: 14px;
  height: 14px;
}

.dropzone {
  position: relative;
  display: grid;
  min-height: 310px;
  margin: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px dashed #aeb4ae;
  background: #eef0ec;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--blue);
  background: #eaf0fb;
}

.dropzone-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.dropzone-empty strong {
  color: var(--ink);
  font-size: 14px;
}

.dropzone-empty span:not(.dropzone-icon) {
  font-size: 12px;
}

.dropzone-empty small {
  font-size: 10px;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.dropzone-icon img {
  width: 20px;
  height: 20px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.preview-layer {
  position: absolute;
  inset: 0;
  background: #4c504c;
}

.preview-image {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.annotation-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.preview-overlay {
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 7px 8px 7px 10px;
  background: rgba(27, 30, 28, 0.88);
  color: #fff;
  font-size: 11px;
}

.preview-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-replace {
  flex: 0 0 auto;
  padding: 3px 0;
  background: transparent;
  color: var(--acid);
  font-size: 11px;
}

.preview-replace img {
  filter: invert(87%) sepia(91%) saturate(584%) hue-rotate(31deg) brightness(105%) contrast(103%);
}

.media-meta {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.annotation-note {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.client-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 15px;
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  color: #234a86;
  font-size: 12px;
}

.client-notice[data-tone="error"] {
  border-left-color: var(--red);
  background: var(--red-soft);
  color: #8c2e29;
}

.client-notice[data-tone="success"] {
  border-left-color: var(--green-ink);
  background: #eef8ef;
  color: var(--green-ink);
}

.workspace-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.workspace-note img {
  width: 14px;
  height: 14px;
}

.result-panel {
  min-width: 0;
  padding: 27px 23px 25px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.result-header {
  margin-bottom: 16px;
}

.result-state {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 800;
}

.status-dot {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  background: #d8ddd8;
}

.result-state[data-status="pass"] .status-dot {
  background: var(--acid);
}

.result-state[data-status="fail"] .status-dot,
.result-state[data-status="invalid"] .status-dot {
  background: var(--red);
}

.result-state[data-status="loading"] .status-dot {
  border-color: var(--blue);
  background: var(--blue);
  animation: pulse-dot 900ms ease-in-out infinite alternate;
}

.result-state[data-status="pass"] strong {
  color: var(--green-ink);
}

.result-state[data-status="fail"] strong,
.result-state[data-status="invalid"] strong {
  color: #a4312b;
}

.result-message {
  min-height: 40px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.metric-block {
  padding: 18px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-top: 7px;
  font-size: 48px;
  font-weight: 850;
  line-height: 1;
}

.metric-value small {
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.ratio-line {
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.ratio-line strong {
  color: var(--ink);
  font-weight: 700;
}

.score-track {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  background: #e3e6e1;
}

.score-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--acid);
  transition: width 240ms ease;
}

.result-state[data-status="fail"] ~ .metric-block .score-track span,
.result-state[data-status="invalid"] ~ .metric-block .score-track span {
  background: var(--red);
}

.metric-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
}

.fact {
  min-width: 0;
  padding: 11px 10px 10px;
  border: 1px solid var(--line);
}

.fact strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.evidence-block,
.pair-block {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.pair-block {
  margin-top: 18px;
}

.evidence-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.evidence-count {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.checklist,
.pair-list {
  margin-top: 7px;
}

.check-row,
.pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  border-bottom: 1px solid #edf0ec;
  color: var(--muted);
  font-size: 11px;
}

.check-row:last-child,
.pair-row:last-child {
  border-bottom: 0;
}

.check-status {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.check-row.is-ok .check-status {
  color: var(--green-ink);
}

.check-row.is-ok .check-status::before {
  content: "✓ ";
}

.check-row.is-error .check-status {
  color: #a4312b;
}

.pair-row strong {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
}

.pair-row.is-error strong {
  color: #a4312b;
}

.result-detail {
  margin: 16px 0 0;
  padding: 9px 10px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: #8c2e29;
  font-size: 11px;
}

.reset-button {
  width: 100%;
  margin-top: 20px;
}

.reset-button img {
  width: 15px;
  height: 15px;
}

[hidden] {
  display: none !important;
}

@keyframes pulse-dot {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

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

@media (max-width: 1020px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .app-bar {
    min-height: 58px;
    padding: 0 16px;
  }

  .brand {
    font-size: 15px;
  }

  .threshold-label {
    display: none;
  }

  .comparison-column {
    padding: 20px 14px 26px;
  }

  .comparison-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .comparison-header .button {
    width: 100%;
  }

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

  .dropzone {
    min-height: 0;
    height: 240px;
    aspect-ratio: auto;
  }

  .result-panel {
    padding: 22px 14px 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
