@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/assets/fonts/unbounded-latin.woff2") format("woff2");
}

:root {
  --paper: #f1f3f0;
  --paper-deep: #e5e9e7;
  --paper-bright: #fafbf8;
  --ink: #171b22;
  --ink-soft: #565e68;
  --rule: #aeb5b8;
  --rule-dark: #727b83;
  --cobalt: #174fc9;
  --cobalt-dark: #103a94;
  --cobalt-wash: #dbe5ff;
  --vermilion: #df432f;
  --vermilion-wash: #f8ded8;
  --amber: #d39717;
  --amber-dark: #765109;
  --amber-wash: #f5e7bd;
  --success: #176d53;
  --on-dark: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI Variable", Aptos, "Segoe UI", sans-serif;
  font-synthesis: none;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(23, 27, 34, 0.028) 1px, transparent 1px) 0 0 / 46px 100%,
    var(--paper);
}

button,
a { -webkit-tap-highlight-color: rgba(23, 79, 201, 0.18); }
button { color: inherit; font: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

::selection { background: var(--cobalt); color: #fff; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--paper-deep); }
::-webkit-scrollbar-thumb { background: var(--rule-dark); border: 3px solid var(--paper-deep); }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 9px 12px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.discover-shell { min-height: 100vh; }
.auth-pending .discover-shell { visibility: hidden; }

.discover-header {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(310px, 1fr);
  align-items: center;
  min-height: 74px;
  padding: 0 20px;
  border-bottom: 1px solid var(--ink);
  background: rgba(250, 251, 248, 0.96);
}

.discover-brand {
  display: inline-flex;
  align-items: center;
  width: max-content;
  color: var(--ink);
  gap: 9px;
  text-decoration: none;
}

.discover-brand img { display: block; flex: 0 0 auto; }

.brand-name {
  font-family: "Unbounded", "Segoe UI Variable", Aptos, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.brand-section {
  color: var(--cobalt);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.product-nav {
  display: flex;
  align-self: stretch;
  border-inline: 1px solid var(--rule);
}

.product-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 98px;
  padding: 0 15px;
  border-right: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 760;
  text-decoration: none;
}

.product-nav a:last-child { border-right: 0; }
.product-nav a:hover { color: var(--ink); background: var(--paper-deep); }
.product-nav a[aria-current="page"] {
  color: var(--cobalt-dark);
  background: var(--cobalt-wash);
  box-shadow: inset 0 -3px 0 var(--cobalt);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  color: var(--ink-soft);
  gap: 7px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
}

.connection-state > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.connection-state[data-state="online"] > span { background: var(--success); }
.connection-state[data-state="error"] > span { background: var(--vermilion); }

.utility-button,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0 12px;
  background: var(--paper-bright);
  color: var(--ink);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}

.utility-button:hover,
.secondary-action:hover { color: #fff; background: var(--ink); }

.primary-action {
  min-height: 44px;
  padding-inline: 20px;
  border-color: var(--cobalt);
  color: #fff;
  background: var(--cobalt);
}

.primary-action:hover { background: var(--cobalt-dark); }

.discover-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 20px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  background: var(--paper-bright);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.035em;
}

.discover-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 22vw) minmax(0, 1fr);
  min-height: calc(100vh - 109px);
}

.niche-index {
  min-width: 0;
  padding: 22px 16px 30px;
  border-right: 1px solid var(--ink);
  background: rgba(241, 243, 240, 0.94);
}

.index-heading,
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.index-heading {
  padding-bottom: 11px;
  border-bottom: 2px solid var(--ink);
}

.index-heading h1,
.sheet-heading h2,
.sheet-empty h2,
.sheet-error h2,
.section-heading h3 { margin: 0; }

.index-heading h1 { font-size: 18px; font-weight: 850; letter-spacing: -0.025em; }
.index-heading span,
.section-heading span {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.index-intro {
  max-width: 28ch;
  margin: 14px 0 20px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}

.niche-list { display: grid; gap: 0; border-top: 1px solid var(--rule-dark); }

.niche-button {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  width: 100%;
  min-height: 76px;
  padding: 13px 11px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.niche-button:hover { background: var(--paper-bright); }
.niche-button[aria-selected="true"] {
  background: var(--cobalt-wash);
  box-shadow: inset 3px 0 0 var(--cobalt);
}

.niche-button strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.niche-button > span {
  color: var(--ink-soft);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.niche-button small {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 10px;
}

.niche-button[aria-selected="true"] strong,
.niche-button[aria-selected="true"] > span { color: var(--cobalt-dark); }

.niche-skeleton {
  height: 76px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(100deg, transparent 25%, rgba(255,255,255,.72) 42%, transparent 60%) 0 0 / 240% 100%, var(--paper-deep);
  animation: scan 1.3s ease-in-out infinite;
}

.niche-sheet {
  position: relative;
  min-width: 0;
  padding: clamp(24px, 4vw, 56px) clamp(20px, 5vw, 74px) 54px;
  background: rgba(250, 251, 248, 0.78);
}

.sheet-content { max-width: 1180px; margin: 0 auto; }

.sheet-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding-bottom: 25px;
  border-bottom: 2px solid var(--ink);
}

.sheet-register {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}

.sheet-register span {
  padding: 4px 6px;
  border: 1px solid var(--rule-dark);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
}

.sheet-register span:first-child { border-color: var(--success); color: var(--success); }

.sheet-heading h2 {
  font-size: clamp(32px, 5vw, 72px);
  font-weight: 880;
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.sheet-heading p {
  max-width: 65ch;
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.sheet-actions { display: flex; flex: 0 0 auto; gap: 8px; }

.workflow-proof { padding: 28px 0 27px; border-bottom: 1px solid var(--ink); }
.section-heading { margin-bottom: 13px; }
.section-heading h3 { font-size: 14px; font-weight: 850; letter-spacing: -0.015em; }
.section-heading span { color: var(--ink-soft); }

.workflow-line {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--rule-dark);
}

.workflow-stage {
  position: relative;
  min-width: 0;
  min-height: 138px;
  padding: 19px 20px 18px;
  border-right: 1px solid var(--rule);
}

.workflow-stage:last-child { border-right: 0; }
.workflow-stage::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 28px;
  z-index: 1;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--rule-dark);
  border-right: 1px solid var(--rule-dark);
  background: var(--paper-bright);
  transform: rotate(45deg);
}
.workflow-stage:last-child::after { display: none; }

.stage-name {
  display: block;
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.workflow-stage strong {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 880;
  line-height: .9;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
}

.workflow-stage p { margin: 0; color: var(--ink-soft); font-size: 10px; line-height: 1.45; }
.stage-review strong { color: var(--cobalt-dark); }
.stage-pool strong { color: var(--cobalt); }

.review-progress { height: 7px; margin-top: 18px; overflow: hidden; background: var(--paper-deep); }
.review-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cobalt);
  transition: width 280ms cubic-bezier(.22,1,.36,1);
}

.progress-caption { margin: 8px 0 0; color: var(--ink-soft); font-size: 10px; }
.progress-caption strong { color: var(--ink); font-family: "Cascadia Mono", Consolas, monospace; }

.sheet-ledgers { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 34px; padding-top: 29px; }
.run-ledger,
.research-ledger { min-width: 0; }
.run-list { border-top: 1px solid var(--rule-dark); }

.run-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 18px;
  padding: 15px 0;
  border-bottom: 1px dotted var(--rule-dark);
}

.run-row strong { font-size: 12px; }
.run-row > span { color: var(--cobalt-dark); font-family: "Cascadia Mono", Consolas, monospace; font-size: 9px; font-weight: 700; }
.run-row p { grid-column: 1 / -1; margin: 0; color: var(--ink-soft); font-size: 10px; }
.run-row a { color: var(--cobalt-dark); font-weight: 750; text-underline-offset: 3px; }

.research-job-state {
  min-height: 128px;
  padding: 18px;
  border-block: 1px solid var(--rule-dark);
  background: var(--paper);
}

.research-job-state strong { display: block; margin-bottom: 8px; font-size: 13px; }
.research-job-state p { margin: 0 0 11px; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.research-job-state dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 10px; }
.research-job-state dt { color: var(--ink-soft); }
.research-job-state dd { margin: 0; text-align: right; font-family: "Cascadia Mono", Consolas, monospace; }

.sheet-loading,
.sheet-empty,
.sheet-error {
  display: grid;
  place-content: center;
  min-height: calc(100vh - 190px);
  text-align: center;
}

.sheet-loading { gap: 12px; }
.sheet-loading span { display: block; width: min(520px, 70vw); height: 18px; background: var(--paper-deep); }
.sheet-loading span:first-child { width: min(260px, 50vw); height: 54px; }
.sheet-loading span:last-child { width: min(410px, 62vw); }

.sheet-empty img { margin: 0 auto 18px; }
.sheet-empty h2,
.sheet-error h2 { max-width: 620px; font-size: clamp(24px, 4vw, 46px); line-height: 1; letter-spacing: -.035em; }
.sheet-empty p,
.sheet-error p { max-width: 58ch; margin: 16px auto 22px; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.sheet-error .secondary-action { margin: 0 auto; }

@keyframes scan { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (max-width: 980px) {
  .discover-header { grid-template-columns: 1fr auto; padding: 0 14px; }
  .product-nav { grid-row: 2; grid-column: 1 / -1; min-height: 44px; margin-inline: -14px; border-top: 1px solid var(--rule); border-inline: 0; }
  .product-nav a { flex: 1; min-width: 0; }
  .header-actions { grid-column: 2; }
  .discover-workspace { min-height: calc(100vh - 153px); }
  .sheet-heading { align-items: flex-start; flex-direction: column; }
  .sheet-actions { width: 100%; }
  .sheet-actions a { flex: 1; }
  .sheet-ledgers { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .discover-header { min-height: 62px; }
  .brand-section,
  .connection-state,
  #refreshButton { display: none; }
  .utility-button { min-height: 40px; padding-inline: 10px; }
  .discover-status { min-height: 32px; padding-inline: 12px; }
  .discover-status span:last-child { display: none; }
  .discover-workspace { display: block; min-height: 0; }
  .niche-index { padding: 15px 12px 0; border-right: 0; border-bottom: 1px solid var(--ink); }
  .index-heading { padding-bottom: 8px; }
  .index-intro { display: none; }
  .niche-list {
    display: flex;
    gap: 0;
    margin-top: 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    border-top: 0;
    scroll-snap-type: x proximity;
  }
  .niche-button { flex: 0 0 min(76vw, 260px); min-height: 58px; padding: 9px 11px; border-top: 1px solid var(--rule); border-right: 1px solid var(--rule); scroll-snap-align: start; }
  .niche-button[aria-selected="true"] { box-shadow: inset 0 3px 0 var(--cobalt); }
  .niche-button small { white-space: nowrap; }
  .niche-skeleton { flex: 0 0 220px; height: 58px; }
  .niche-sheet { padding: 24px 14px max(36px, env(safe-area-inset-bottom)); }
  .sheet-heading { gap: 22px; padding-bottom: 21px; }
  .sheet-heading h2 { font-size: clamp(38px, 13vw, 58px); }
  .sheet-heading p { font-size: 11px; }
  .sheet-actions { position: sticky; z-index: 4; bottom: max(8px, env(safe-area-inset-bottom)); order: 2; background: rgba(250, 251, 248, .96); }
  .sheet-actions a { min-height: 48px; }
  .workflow-proof { padding-top: 24px; }
  .workflow-line { grid-template-columns: 1fr; }
  .workflow-stage { min-height: 96px; padding: 14px 12px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .workflow-stage:last-child { border-bottom: 0; }
  .workflow-stage::after { top: auto; right: 22px; bottom: -7px; transform: rotate(135deg); }
  .stage-name { margin-bottom: 7px; }
  .workflow-stage strong { font-size: 38px; }
  .sheet-ledgers { gap: 27px; padding-top: 24px; }
  .run-row { grid-template-columns: 1fr; gap: 5px; }
  .run-row p { grid-column: 1; }
}

@media (max-width: 430px) {
  .discover-header { padding-inline: 10px; }
  .discover-brand { gap: 7px; }
  .discover-brand img { width: 25px; height: 25px; }
  .product-nav { margin-inline: -10px; }
  .product-nav a { min-height: 44px; padding-inline: 8px; font-size: 10px; }
  .sheet-actions { flex-direction: column; }
  .sheet-actions a { width: 100%; }
  .workflow-stage p { max-width: 30ch; }
}

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