:root {
  color-scheme: light;
  --ink: #171512;
  --ink-soft: #4c463d;
  --paper: #f3efe7;
  --paper-bright: #fffaf0;
  --line: #252018;
  --blue: #2248ff;
  --green: #c8ff3d;
  --red: #e23d31;
  --gold: #ffb627;
  --shadow: 0 18px 45px rgba(23, 21, 18, 0.12);
  --max: 1440px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 21, 18, 0.05) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    radial-gradient(rgba(23, 21, 18, 0.08) 0.7px, transparent 0.7px);
  background-size: 12px 12px;
  opacity: 0.38;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="search"],
input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper-bright);
}

button {
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
  box-shadow: 3px 3px 0 var(--ink);
  transition:
    transform 130ms ease,
    box-shadow 130ms ease,
    background 130ms ease;
}

button:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

button:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

a {
  color: inherit;
}

select,
input[type="search"],
input[type="text"] {
  min-height: 42px;
  padding: 0 12px;
}

input[type="search"] {
  width: 100%;
  font-size: clamp(1.5rem, 3.4vw, 3.4rem);
  font-weight: 820;
  line-height: 1;
  background: transparent;
  border-width: 0 0 2px;
  border-radius: 0;
  outline: none;
}

input[type="search"]::placeholder {
  color: rgba(23, 21, 18, 0.34);
}

input[type="range"] {
  accent-color: var(--red);
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 12px;
  z-index: 10;
  padding: 8px 12px;
  transform: translateY(-160%);
  color: var(--paper-bright);
  background: var(--ink);
}

.skip-link:focus {
  transform: none;
}

.masthead,
.workspace {
  width: min(calc(100% - 28px), var(--max));
  margin: 0 auto;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 24px;
  align-items: end;
  padding: 32px 0 18px;
}

.masthead__copy {
  position: relative;
  min-height: 210px;
  padding-top: 24px;
  border-top: 4px solid var(--ink);
}

.masthead__copy::after {
  position: absolute;
  right: 12%;
  bottom: 14px;
  width: 128px;
  height: 28px;
  content: "";
  background: var(--green);
  border: 1px solid var(--ink);
  transform: rotate(-3deg);
}

.kicker {
  display: inline-block;
  margin: 0 0 16px;
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 780;
  text-transform: uppercase;
  background: var(--red);
  color: var(--paper-bright);
  border: 1px solid var(--ink);
}

h1 {
  max-width: 980px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.4rem, 12vw, 10.6rem);
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 0;
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  transform: rotate(1deg);
}

.stat-strip div {
  min-width: 0;
  padding: 18px 16px;
  background: var(--paper-bright);
  border-right: 1px solid var(--ink);
}

.stat-strip div:last-child {
  border-right: 0;
}

.stat-strip dt {
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-strip dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  line-height: 0.9;
}

.workspace {
  padding: 0 0 56px;
}

.api-room {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(360px, 1.25fr);
  gap: 18px;
  align-items: stretch;
  margin-top: 22px;
  padding: clamp(16px, 2.4vw, 28px);
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--ink);
  box-shadow: 8px 8px 0 var(--gold);
}

.api-room > *,
.api-outputs,
.api-output,
.api-output span {
  min-width: 0;
  max-width: 100%;
}

.api-copy {
  min-width: 0;
  padding-right: 10px;
}

.api-copy h2,
.api-preview h3 {
  margin: 0;
  letter-spacing: 0;
}

.api-copy h2 {
  max-width: min(520px, 100%);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.3rem);
  font-weight: 900;
  line-height: 0.92;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.api-copy p {
  max-width: 520px;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.45;
}

.api-form {
  display: grid;
  grid-column: 2;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 160px) auto;
  gap: 12px;
  align-items: end;
  min-width: 0;
}

.api-form label,
.api-output,
.api-status {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 820;
  text-transform: uppercase;
}

.api-form label,
.api-output {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.api-form input,
.api-form select {
  width: 100%;
}

.api-preview {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-width: 0;
  padding: 14px;
  background: var(--paper-bright);
  border: 1px solid var(--ink);
}

.api-preview__stage {
  display: grid;
  place-items: center;
  width: 148px;
  aspect-ratio: 1;
  padding: 14px;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(23, 21, 18, 0.045) 25%, transparent 25%) 0 0 / 16px 16px,
    #fff;
  border: 1px solid rgba(23, 21, 18, 0.2);
}

.api-preview__stage img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
}

.api-preview__stage img:not([src]) {
  display: none;
}

.api-preview__copy {
  min-width: 0;
}

.api-preview .exchange {
  display: inline-block;
  margin-bottom: 9px;
}

.api-preview h3 {
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.api-preview p {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.api-preview p:first-of-type {
  font-weight: 760;
}

.api-preview p:last-of-type {
  color: var(--ink-soft);
  font-size: 0.84rem;
  word-break: break-all;
}

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

.api-output--wide {
  grid-column: 1 / -1;
}

.api-output span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.api-output input {
  min-width: 0;
  width: 100%;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  text-transform: none;
}

.api-output button:disabled {
  cursor: not-allowed;
}

.api-status {
  grid-column: 1 / -1;
  margin: 0;
}

.control-room,
.download-room,
.result-bar {
  border: 1px solid var(--ink);
  background: rgba(255, 250, 240, 0.88);
}

.control-room {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 28px;
  align-items: end;
  margin-top: 22px;
  padding: clamp(18px, 3vw, 32px);
  box-shadow: -8px 8px 0 var(--blue);
}

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

.search-label,
.filters label,
.download-room label,
.segment-field legend {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 820;
  text-transform: uppercase;
}

.search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

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

.filters label,
.download-room label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.filters select,
.download-room select {
  width: 100%;
}

.download-room {
  display: grid;
  grid-template-columns: auto minmax(110px, 150px) minmax(180px, 1fr) auto auto;
  gap: 16px;
  align-items: end;
  margin-top: 20px;
  padding: 16px;
}

.segment-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segment-field legend {
  width: 100%;
  margin-bottom: 7px;
}

.segment-field label {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
}

.segment-field input {
  margin-right: 8px;
  accent-color: var(--blue);
}

.quality-control {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.quality-control input {
  grid-column: 1 / -1;
}

.quality-control span {
  color: var(--red);
}

.result-bar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin: 28px 0 16px;
  padding: 13px 16px;
}

.result-bar p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin: 0;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86rem;
  text-transform: uppercase;
}

.result-bar strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 99px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.logo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(286px, 1fr));
  gap: 18px;
}

.logo-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  min-height: 450px;
  padding: 14px;
  overflow: hidden;
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(23, 21, 18, 0.92);
}

.logo-card:nth-child(6n + 2) {
  transform: translateY(8px);
}

.logo-card:nth-child(6n + 4) {
  transform: translateY(-5px);
}

.logo-card.is-selected {
  background: #f9ffd7;
  box-shadow: 4px 4px 0 var(--green);
}

.check-pin {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  width: max-content;
  margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.check-pin input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.logo-stage {
  display: grid;
  place-items: center;
  height: clamp(188px, 17vw, 248px);
  margin-bottom: 18px;
  padding: clamp(14px, 2vw, 20px);
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(23, 21, 18, 0.045) 25%, transparent 25%) 0 0 / 18px 18px,
    #fff;
  border: 1px solid rgba(23, 21, 18, 0.2);
}

.logo-stage img {
  display: block;
  width: auto;
  height: min(100%, 208px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ticker-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  margin-bottom: 8px;
}

.exchange {
  flex: 0 0 auto;
  padding: 4px 7px;
  color: var(--paper-bright);
  background: var(--ink);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 820;
}

.logo-card h2 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.2rem;
  line-height: 1.05;
}

.company,
.industry {
  margin: 0;
  overflow-wrap: anywhere;
}

.company {
  font-size: 0.97rem;
  font-weight: 760;
  line-height: 1.22;
}

.industry {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.35;
}

.meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 12px;
}

.meta-row div {
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(23, 21, 18, 0.22);
}

.meta-row dt {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 820;
  text-transform: uppercase;
}

.meta-row dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  line-height: 1.2;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  align-items: center;
}

.card-actions button,
.card-actions a {
  display: grid;
  min-height: 40px;
  place-items: center;
  min-width: 0;
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.card-actions a {
  border: 1px solid var(--ink);
  border-radius: 6px;
}

.load-row {
  display: flex;
  justify-content: center;
  padding: 30px 0 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: var(--paper-bright);
  background: var(--ink);
  border: 1px solid var(--paper-bright);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 220px;
  padding: 36px;
  color: var(--ink-soft);
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 5vw, 3.6rem);
  font-weight: 900;
  line-height: 0.95;
}

@media (max-width: 980px) {
  .masthead,
  .api-room,
  .control-room,
  .download-room {
    grid-template-columns: 1fr;
  }

  .api-form,
  .api-preview {
    grid-column: auto;
  }

  .masthead__copy {
    min-height: 0;
  }

  .stat-strip {
    transform: none;
  }
}

@media (max-width: 700px) {
  .masthead,
  .workspace {
    width: min(calc(100% - 18px), var(--max));
  }

  .masthead {
    padding-top: 20px;
  }

  .masthead__copy::after {
    display: none;
  }

  h1 {
    font-size: clamp(2.85rem, 13vw, 3.45rem);
    line-height: 0.9;
  }

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

  .search-line {
    grid-template-columns: 1fr;
  }

  .download-room {
    gap: 12px;
  }

  .api-form,
  .api-outputs {
    grid-template-columns: 1fr;
  }

  .api-copy,
  .api-form,
  .api-preview,
  .api-outputs {
    width: min(100%, calc(100vw - 72px));
  }

  .api-copy h2,
  .api-copy p {
    max-width: calc(100vw - 72px);
  }

  .api-copy h2 {
    font-size: clamp(1.75rem, 7vw, 2.2rem);
    line-height: 0.98;
  }

  .api-output--wide {
    grid-column: auto;
  }

  .api-preview {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .api-preview__stage {
    width: 112px;
  }

  .download-room > button {
    width: 100%;
  }

  .result-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions button {
    flex: 1 1 140px;
  }

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

  .logo-card:nth-child(n) {
    transform: none;
  }
}

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