:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d100d;
  color: #f6f4eb;
  --surface: #171b16;
  --surface-raised: #1e241d;
  --line: #30382f;
  --muted: #aab3a6;
  --accent: #d8ef62;
  --accent-ink: #15190f;
  --green: #16a765;
  --orange: #f59e0b;
  --red: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -20%, #26301f 0, transparent 42%),
    #0d100d;
}

button,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100% - 28px, 760px);
  margin: 0 auto;
  padding: 44px 0 72px;
}

.hero {
  margin: 0 4px 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 620px;
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 9vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.intro {
  max-width: 590px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 18px 50px rgb(0 0 0 / 24%);
}

.upload-panel {
  padding: 22px;
  text-align: center;
}

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

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0 20px;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: #f6f4eb;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.upload-button:focus-within,
input:focus-visible {
  outline: 3px solid rgb(216 239 98 / 35%);
  outline-offset: 3px;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.upload-button {
  width: 100%;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  margin-top: 18px;
}

.status {
  min-height: 22px;
  margin: 14px 4px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.status.loading::after {
  content: "...";
  display: inline-block;
  width: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
  animation: pending 1.15s steps(4, end) infinite;
}

.status.error {
  color: #ff9b9b;
}

@keyframes pending {
  from {
    width: 0;
  }

  to {
    width: 1.2em;
  }
}

.image-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #070807;
  line-height: 0;
  box-shadow: 0 18px 50px rgb(0 0 0 / 30%);
}

.image-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-overlay {
  position: absolute;
  border: 2px solid var(--card-color);
  border-radius: 4px;
  background: color-mix(in srgb, var(--card-color) 38%, transparent);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 36%);
}

.card-label {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 26px;
  border-radius: 5px;
  padding: 3px 5px;
  background: rgb(10 12 10 / 88%);
  color: #fff;
  font-size: clamp(0.58rem, 2.1vw, 0.76rem);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
}

.overlay.hide-labels .card-label {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

.status {
  min-height: 24px;
  margin: 16px 4px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.status.error {
  color: #ff8e94;
}

.status.loading::after {
  display: inline-block;
  width: 1.1em;
  overflow: hidden;
  vertical-align: bottom;
  content: "...";
  animation: loading-dots 1.2s steps(4, end) infinite;
}

@keyframes loading-dots {
  from {
    width: 0;
  }
}

.results {
  margin-top: 10px;
  padding: 20px;
}

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

.label-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}

.label-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}

.summary-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #e6e8e3;
  font-size: 0.86rem;
  font-weight: 650;
}

.summary-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--summary-color);
}

.thresholds {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.45;
}

.warnings {
  margin-bottom: 14px;
  border: 1px solid rgb(245 158 11 / 38%);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgb(245 158 11 / 8%);
  color: #f7cf88;
  font-size: 0.82rem;
  line-height: 1.45;
}

.warnings p {
  margin: 0;
}

.warnings p + p {
  margin-top: 6px;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.card-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #121612;
}

.card-value {
  display: grid;
  width: 34px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--card-color);
  border-radius: 6px;
  background: rgb(255 255 255 / 94%);
  color: #171917;
  font-size: 0.95rem;
  font-weight: 850;
}

.card-position {
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.card-position strong {
  display: block;
  overflow: hidden;
  color: #eff1eb;
  font-size: 0.79rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-width {
  width: 100%;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 760px);
    padding-top: 28px;
  }

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

  .results-heading {
    align-items: flex-start;
  }

  .card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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