:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #62615b;
  --paper: #f7f5ef;
  --surface: #fffdfa;
  --line: #ded8cc;
  --cyan: #0c94a6;
  --coral: #d85c49;
  --gold: #d6a840;
  --moss: #64765c;
  --shadow: 0 20px 60px rgba(21, 21, 21, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  background:
    linear-gradient(90deg, rgba(12, 148, 166, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(216, 92, 73, 0.08) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: 44px 44px;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  background: conic-gradient(from 210deg, var(--cyan), var(--coral), var(--gold), var(--cyan));
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.chrome-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.icon-link,
.search-form button,
.modal-close {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 253, 250, 0.8);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-link {
  text-decoration: none;
}

.icon-button:hover,
.icon-link:hover,
.search-form button:hover,
.modal-close:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
  background: var(--surface);
}

.icon-button:focus-visible,
.icon-link:focus-visible,
.search-form button:focus-visible,
.modal-close:focus-visible,
.sample-row button:focus-visible,
.search-form input:focus-visible {
  outline: 3px solid rgba(12, 148, 166, 0.25);
  outline-offset: 3px;
}

svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 5;
  padding: 5px 8px;
  border-radius: 6px;
  color: #fff;
  background: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.tooltip:hover::after,
.tooltip:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 22px;
  align-items: stretch;
  padding: 26px 0 18px;
}

.query-panel,
.signal-panel {
  border: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.92);
  box-shadow: var(--shadow);
}

.query-panel {
  padding: 34px;
}

.signal-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
}

.eyebrow,
.section-heading span,
.signal-label {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0 0 24px;
  font-size: 44px;
  line-height: 1.08;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px;
  max-width: 760px;
}

.search-form input {
  min-width: 0;
  height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(21, 21, 21, 0.04);
}

.search-form button {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.sample-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.sample-row button:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.signal-panel strong {
  display: block;
  font-size: 28px;
  line-height: 1.15;
}

.source-strip {
  display: grid;
  gap: 8px;
}

.source-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 245, 239, 0.72);
  font-size: 13px;
}

.source-chip[data-ok="true"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--moss);
}

.source-chip[data-skipped="true"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.source-chip[data-ok="false"][data-skipped="false"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
}

.thesis-band {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.55fr) minmax(160px, 0.25fr);
  gap: 18px;
  align-items: center;
  padding: 18px 0 28px;
  border-bottom: 1px solid var(--line);
}

.thesis-band span {
  color: var(--muted);
  font-size: 13px;
}

.thesis-band p {
  margin: 4px 0 0;
  font-size: 19px;
}

.facet-list {
  display: grid;
  gap: 8px;
}

.facet {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) 90px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.facet-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(21, 21, 21, 0.08);
}

.facet-meter i {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--coral));
}

.palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.palette span {
  display: block;
  height: 54px;
  border: 1px solid rgba(21, 21, 21, 0.12);
  border-radius: 8px;
  background: var(--swatch);
}

.status-line {
  min-height: 42px;
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.results {
  display: grid;
  gap: 44px;
  padding: 12px 0 48px;
}

.result-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 28px;
}

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

.rec-card {
  display: grid;
  grid-template-rows: 178px auto;
  min-height: 422px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.poster {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(12, 148, 166, 0.42), transparent 34%),
    radial-gradient(circle at 70% 70%, rgba(216, 92, 73, 0.36), transparent 36%),
    #202124;
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.88);
  font-size: 42px;
  font-weight: 900;
}

.card-body {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 16px;
}

.card-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid rgba(21, 21, 21, 0.12);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(247, 245, 239, 0.72);
}

.rec-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.reason {
  margin: 0;
  color: #30302d;
  font-size: 14px;
}

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

.card-actions a,
.audio-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.card-actions a:hover,
.audio-link:hover {
  color: var(--coral);
}

.visual-grid .rec-card {
  grid-template-rows: 112px auto;
  min-height: 330px;
}

.visual-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 112px;
}

.visual-swatches span {
  background: var(--swatch);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.site-footer a {
  color: var(--ink);
  font-weight: 700;
  text-decoration-color: rgba(216, 92, 73, 0.45);
  text-underline-offset: 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(21, 21, 21, 0.52);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(420px, 100%);
  max-height: min(680px, calc(100vh - 44px));
  overflow: auto;
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.modal h2 {
  margin: 0 44px 18px 0;
  font-size: 24px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
}

.qr-layout {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.qr-layout img {
  width: min(280px, 100%);
  height: auto;
  border-radius: 8px;
}

.modal-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.loading .rec-card {
  opacity: 0.62;
}

@media (max-width: 980px) {
  .workbench,
  .thesis-band {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 36px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .site-header {
    min-height: 68px;
  }

  .brand small {
    display: none;
  }

  .chrome-actions {
    gap: 6px;
  }

  .icon-button,
  .icon-link {
    width: 38px;
    height: 38px;
  }

  .query-panel,
  .signal-panel {
    padding: 18px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.15;
  }

  .search-form {
    grid-template-columns: 1fr 48px;
  }

  .search-form input,
  .search-form button {
    height: 48px;
  }

  .search-form input {
    padding: 0 12px;
  }

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

  .rec-card {
    grid-template-rows: 168px auto;
    min-height: 380px;
  }

  .section-heading h2 {
    font-size: 24px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}
