@layer reset, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
  body, h1, h2, h3, p, ol, ul, blockquote { margin: 0; }
  button, textarea, input { font: inherit; }
  button, a { -webkit-tap-highlight-color: transparent; }
}

@layer base {
  :root {
    color-scheme: light;
    --paper: #f3efe5;
    --paper-deep: #eae4d8;
    --ink: #151511;
    --ink-soft: #44433d;
    --muted: #747168;
    --line: #cbc5b9;
    --line-dark: #9b978d;
    --signal: #ff4e3e;
    --signal-dark: #c62920;
    --blue: #3159f5;
    --green: #158360;
    --white: #fffdf7;
    --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --page: min(1240px, calc(100vw - 48px));
    --reading: min(780px, calc(100vw - 48px));
  }

  body {
    min-width: 320px;
    min-height: 100vh;
    background:
      linear-gradient(90deg, transparent calc(50% - .5px), rgba(21,21,17,.045) 50%, transparent calc(50% + .5px)),
      var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
  }

  ::selection { background: var(--signal); color: var(--white); }
  a { color: inherit; }
  button { color: inherit; }
  :focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
}

@layer components {
  .skip-link {
    position: fixed;
    z-index: 1000;
    top: 12px;
    left: 12px;
    transform: translateY(-150%);
    padding: 10px 14px;
    background: var(--ink);
    color: var(--white);
    text-decoration: none;
  }
  .skip-link:focus { transform: translateY(0); }

  .site-header {
    position: sticky;
    z-index: 50;
    top: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 72px;
    padding: 0 max(24px, calc((100vw - 1240px) / 2));
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(14px);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 11px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .155em;
    text-decoration: none;
  }

  .brand-mark {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 17px;
  }
  .brand-mark i {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
  }
  .brand-mark i:nth-child(2) { width: 72%; }
  .brand-mark i:nth-child(3) { width: 45%; background: var(--signal); }

  .site-nav { display: flex; align-items: center; gap: 7px; }
  .site-nav a {
    position: relative;
    padding: 9px 13px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .045em;
    text-decoration: none;
  }
  .site-nav a:hover { color: var(--ink); }
  .site-nav a.active { background: var(--ink); color: var(--paper); }
  .header-note {
    justify-self: end;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  #app { min-height: calc(100vh - 144px); }
  .view { animation: view-in .34s cubic-bezier(.2,.7,.25,1) both; }
  @keyframes view-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .boot-screen {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: calc(100vh - 144px);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .boot-mark {
    width: 38px;
    height: 38px;
    margin-bottom: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--signal);
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .ask-view { width: var(--page); margin: 0 auto; padding: clamp(72px, 10vw, 145px) 0 100px; }
  .hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(380px, .72fr);
    align-items: end;
    gap: clamp(44px, 7vw, 110px);
  }
  .kicker {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--signal-dark);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
  }
  .kicker::before { width: 30px; height: 2px; background: currentColor; content: ""; }
  .hero-title {
    max-width: 820px;
    margin-top: 25px;
    font-family: var(--display);
    font-size: clamp(4.2rem, 9.2vw, 9.2rem);
    font-weight: 400;
    letter-spacing: -.075em;
    line-height: .79;
  }
  .hero-title em { color: var(--signal); font-style: italic; }
  .hero-title .small-line {
    display: block;
    margin-top: .18em;
    font-family: var(--sans);
    font-size: .27em;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1;
    text-transform: uppercase;
  }
  .hero-copy {
    max-width: 545px;
    margin-top: 38px;
    color: var(--ink-soft);
    font-family: var(--display);
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    line-height: 1.47;
  }

  .ask-card {
    position: relative;
    padding: 28px;
    border: 1px solid var(--ink);
    background: var(--white);
    box-shadow: 12px 12px 0 var(--ink);
  }
  .ask-card::before {
    position: absolute;
    top: -12px;
    right: 20px;
    padding: 5px 9px;
    background: var(--signal);
    color: var(--white);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .11em;
    text-transform: uppercase;
    content: "Ask once";
  }
  .ask-card label {
    display: block;
    margin-bottom: 15px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .question-field {
    display: block;
    width: 100%;
    min-height: 168px;
    resize: vertical;
    padding: 0 0 18px;
    border: 0;
    border-bottom: 1px solid var(--line-dark);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--display);
    font-size: 1.55rem;
    line-height: 1.35;
  }
  .question-field::placeholder { color: #aaa49a; }
  .question-field:focus { border-bottom-color: var(--ink); outline: 0; }
  .field-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .04em;
  }
  .ask-error {
    min-height: 24px;
    color: var(--signal-dark);
    font-size: 12px;
    font-weight: 650;
  }
  .submit-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 58px;
    padding: 0 20px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--white);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    transition: background .18s ease, color .18s ease, transform .18s ease;
  }
  .submit-button:hover:not(:disabled) { background: var(--signal); transform: translate(-2px, -2px); }
  .submit-button:disabled { cursor: wait; opacity: .62; }
  .submit-button .arrow { font-size: 22px; font-weight: 400; }

  .examples { margin-top: 26px; }
  .examples-label {
    margin-bottom: 10px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .example-list { display: flex; flex-wrap: wrap; gap: 7px; }
  .example-chip {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 11px;
    transition: border-color .15s, background .15s;
  }
  .example-chip:hover { border-color: var(--ink); background: var(--white); }

  .process-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: clamp(80px, 10vw, 135px);
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
  }
  .process-step {
    position: relative;
    min-height: 142px;
    padding: 22px 25px;
    border-right: 1px solid var(--line-dark);
  }
  .process-step:last-child { border-right: 0; }
  .process-number {
    color: var(--signal);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
  }
  .process-step h2 { margin-top: 25px; font-family: var(--display); font-size: 1.7rem; font-weight: 400; }
  .process-step p { margin-top: 5px; color: var(--muted); font-size: 12px; }
  .process-model {
    position: absolute;
    top: 22px;
    right: 23px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .07em;
    text-transform: uppercase;
  }

  .live-view { width: var(--page); margin: 0 auto; padding: 54px 0 105px; }
  .live-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 33px;
  }
  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .07em;
    text-decoration: none;
    text-transform: uppercase;
  }
  .back-link:hover { color: var(--ink); }
  .run-id { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .07em; }
  .live-question {
    max-width: 1000px;
    font-family: var(--display);
    font-size: clamp(2.8rem, 6vw, 6.6rem);
    font-weight: 400;
    letter-spacing: -.055em;
    line-height: .96;
  }

  .progress-rail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 48px 0 28px;
    border-top: 1px solid var(--line-dark);
  }
  .rail-step {
    position: relative;
    padding: 13px 10px 0 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .rail-step::before {
    position: absolute;
    top: -4px;
    left: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--line-dark);
    content: "";
  }
  .rail-step.live { color: var(--ink); }
  .rail-step.live::before { background: var(--signal); box-shadow: 0 0 0 5px color-mix(in srgb, var(--signal) 16%, transparent); animation: pulse 1.5s ease infinite; }
  .rail-step.done { color: var(--green); }
  .rail-step.done::before { background: var(--green); }
  @keyframes pulse { 50% { box-shadow: 0 0 0 9px transparent; } }

  .thread { display: grid; gap: 18px; }
  .stage-card {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    min-height: 240px;
    border: 1px solid var(--line-dark);
    background: color-mix(in srgb, var(--white) 54%, transparent);
  }
  .stage-card.challenge { border-color: var(--ink); background: var(--ink); color: var(--paper); }
  .stage-card.verdict { border-width: 2px; border-color: var(--signal); background: var(--white); }
  .stage-aside {
    position: relative;
    padding: 25px 22px;
    border-right: 1px solid currentColor;
    border-right-color: color-mix(in srgb, currentColor 22%, transparent);
  }
  .stage-number { color: var(--signal); font-family: var(--mono); font-size: 10px; font-weight: 700; }
  .stage-name { margin-top: 18px; font-family: var(--display); font-size: 1.45rem; font-weight: 400; }
  .stage-role { margin-top: 5px; color: color-mix(in srgb, currentColor 62%, transparent); font-size: 10px; line-height: 1.4; }
  .model-badge {
    position: absolute;
    bottom: 22px;
    left: 22px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: .07em;
    text-transform: uppercase;
  }
  .model-badge::before { width: 6px; height: 6px; border-radius: 50%; background: var(--line-dark); content: ""; }
  .model-badge.live::before { background: var(--signal); animation: pulse-dot 1s infinite; }
  .model-badge.done::before { background: var(--green); }
  @keyframes pulse-dot { 50% { opacity: .25; } }
  .stage-content { min-width: 0; padding: clamp(26px, 4vw, 48px); }
  .stage-status {
    margin-bottom: 18px;
    color: color-mix(in srgb, currentColor 58%, transparent);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .stage-text {
    max-width: 800px;
    overflow-wrap: anywhere;
    font-family: var(--display);
    font-size: clamp(1.08rem, 1.8vw, 1.32rem);
    line-height: 1.62;
  }
  .stage-card.verdict .stage-text { font-size: clamp(1.28rem, 2.2vw, 1.72rem); line-height: 1.52; }
  .stage-text p + p, .stage-text ul + p, .stage-text p + ul { margin-top: 1em; }
  .stage-text ul, .stage-text ol { padding-left: 1.3em; }
  .stage-text li + li { margin-top: .35em; }
  .stage-text h2, .stage-text h3 { margin: 1.1em 0 .35em; font-family: var(--sans); font-size: .8em; letter-spacing: .04em; text-transform: uppercase; }
  .stage-text a { text-decoration-color: var(--signal); text-underline-offset: 3px; }
  .stage-text code { padding: .08em .28em; background: color-mix(in srgb, currentColor 8%, transparent); font-family: var(--mono); font-size: .78em; }
  .waiting-copy {
    display: flex;
    align-items: center;
    gap: 10px;
    color: color-mix(in srgb, currentColor 46%, transparent);
    font-family: var(--sans);
    font-size: 12px;
  }
  .waiting-copy::before { width: 20px; height: 1px; background: currentColor; content: ""; }
  .stream-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 4px;
    vertical-align: -.1em;
    background: var(--signal);
    animation: blink .8s step-end infinite;
  }
  @keyframes blink { 50% { opacity: 0; } }

  .source-list { display: grid; gap: 8px; margin-top: 28px; padding: 0; list-style: none; }
  .source-list a {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-family: var(--sans);
    font-size: 11px;
    text-decoration: none;
  }
  .source-list a:hover { color: var(--signal-dark); }
  .source-list a > span { min-width: 0; }
  .source-list a > span:nth-child(2) { overflow-wrap: anywhere; }
  .source-index { color: var(--signal); font-family: var(--mono); }
  .source-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .lock-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 22px;
    padding: 22px 24px;
    border: 1px solid var(--green);
    background: color-mix(in srgb, var(--green) 8%, var(--paper));
  }
  .lock-copy { display: flex; align-items: center; gap: 13px; }
  .lock-icon {
    display: grid;
    width: 35px;
    height: 35px;
    place-items: center;
    border-radius: 50%;
    background: var(--green);
    color: var(--white);
    font-size: 16px;
  }
  .lock-copy strong { display: block; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
  .lock-copy span { color: var(--muted); font-size: 11px; }
  .lock-actions { display: flex; gap: 8px; }
  .small-button {
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--ink);
    background: transparent;
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-decoration: none;
    text-transform: uppercase;
  }
  a.small-button { display: inline-flex; align-items: center; }
  .small-button.primary { background: var(--ink); color: var(--white); }
  .small-button:hover { border-color: var(--signal); }

  .failed-panel {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid var(--signal-dark);
    background: color-mix(in srgb, var(--signal) 8%, var(--paper));
    color: var(--signal-dark);
    font-size: 13px;
  }

  .library-view, .method-view { width: var(--page); margin: 0 auto; padding: 82px 0 110px; }
  .view-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: end;
    gap: 40px;
    padding-bottom: 34px;
    border-bottom: 1px solid var(--ink);
  }
  .view-title { font-family: var(--display); font-size: clamp(3.5rem, 8vw, 8rem); font-weight: 400; letter-spacing: -.07em; line-height: .85; }
  .view-intro { max-width: 520px; justify-self: end; color: var(--ink-soft); font-family: var(--display); font-size: 1.25rem; line-height: 1.5; }
  .library-list { display: grid; }
  .library-item {
    display: grid;
    grid-template-columns: 75px minmax(0, 1fr) 190px;
    align-items: start;
    gap: 20px;
    padding: 28px 0;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    transition: padding-left .18s ease, color .18s ease;
  }
  .library-item:hover { padding-left: 10px; color: var(--signal-dark); }
  .library-index { padding-top: 6px; color: var(--signal); font-family: var(--mono); font-size: 10px; }
  .library-question { font-family: var(--display); font-size: clamp(1.4rem, 2.6vw, 2.2rem); line-height: 1.15; }
  .library-answer { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }
  .library-date { padding-top: 6px; color: var(--muted); font-family: var(--mono); font-size: 9px; text-align: right; text-transform: uppercase; }
  .empty-state { padding: 70px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--display); font-size: 1.5rem; }
  .skeleton-row { height: 126px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
  @keyframes shimmer { to { background-position: -200% 0; } }

  .method-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 60px;
    border: 1px solid var(--ink);
  }
  .method-card { min-height: 350px; padding: 28px; border-right: 1px solid var(--ink); }
  .method-card:last-child { border-right: 0; }
  .method-card:nth-child(2) { background: var(--ink); color: var(--paper); }
  .method-card .number { color: var(--signal); font-family: var(--mono); font-size: 10px; }
  .method-card h2 { margin-top: 75px; font-family: var(--display); font-size: 2.35rem; font-weight: 400; line-height: 1; }
  .method-card p { margin-top: 18px; color: color-mix(in srgb, currentColor 66%, transparent); font-size: 13px; }
  .method-card .model { display: inline-block; margin-top: 35px; padding: 6px 9px; border: 1px solid currentColor; font-family: var(--mono); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
  .principles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    margin-top: 70px;
    background: var(--line);
    border: 1px solid var(--line);
  }
  .principle { min-height: 170px; padding: 27px; background: var(--paper); }
  .principle h3 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; }
  .principle p { margin-top: 10px; color: var(--muted); font-size: 13px; }

  .site-footer {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    width: var(--page);
    margin: 0 auto;
    padding: 28px 0 38px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
  }
  .site-footer p { max-width: 480px; }
  .noscript { margin: 20px; padding: 20px; border: 1px solid var(--signal); background: var(--white); }

  .toast {
    position: fixed;
    z-index: 100;
    right: 20px;
    bottom: 20px;
    max-width: min(360px, calc(100vw - 40px));
    padding: 13px 16px;
    background: var(--ink);
    color: var(--white);
    font-size: 12px;
    box-shadow: 6px 6px 0 var(--signal);
    animation: toast-in .2s ease both;
  }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

  @media (max-width: 900px) {
    .site-header { grid-template-columns: 1fr auto; }
    .header-note { display: none; }
    .hero-grid { grid-template-columns: 1fr; align-items: start; }
    .ask-card { max-width: 620px; }
    .stage-card { grid-template-columns: 135px minmax(0, 1fr); }
    .method-grid { grid-template-columns: 1fr; }
    .method-card { min-height: auto; border-right: 0; border-bottom: 1px solid var(--ink); }
    .method-card:last-child { border-bottom: 0; }
    .method-card h2 { margin-top: 36px; }
  }

  @media (max-width: 650px) {
    :root { --page: calc(100vw - 28px); --reading: calc(100vw - 28px); }
    body { background: var(--paper); }
    .site-header { min-height: 62px; padding: 0 14px; }
    .site-nav { gap: 0; }
    .site-nav a { padding: 8px 9px; font-size: 10px; }
    .brand { font-size: 10px; }
    .brand-mark { display: none; }
    .ask-view { padding-top: 55px; }
    .hero-title { font-size: clamp(3.8rem, 21vw, 6.1rem); }
    .hero-copy { margin-top: 27px; font-size: 1.1rem; }
    .ask-card { padding: 21px; box-shadow: 7px 7px 0 var(--ink); }
    .question-field { min-height: 140px; font-size: 1.25rem; }
    .process-strip { grid-template-columns: 1fr; }
    .process-step { min-height: 118px; border-right: 0; border-bottom: 1px solid var(--line-dark); }
    .process-step:last-child { border-bottom: 0; }
    .live-view { padding-top: 30px; }
    .live-question { font-size: 2.6rem; }
    .progress-rail { margin-top: 35px; }
    .rail-step { font-size: 7px; }
    .stage-card { grid-template-columns: 1fr; }
    .stage-aside { min-height: 100px; padding: 17px; border-right: 0; border-bottom: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
    .stage-name { margin-top: 7px; font-size: 1.25rem; }
    .stage-role { max-width: 210px; }
    .model-badge { right: 17px; bottom: 17px; left: auto; }
    .stage-content { min-height: 180px; padding: 24px 18px 30px; }
    .lock-panel { align-items: flex-start; flex-direction: column; }
    .lock-actions { width: 100%; }
    .small-button { flex: 1; justify-content: center; }
    .view-header { grid-template-columns: 1fr; }
    .view-intro { justify-self: start; }
    .library-item { grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
    .library-date { display: none; }
    .principles { grid-template-columns: 1fr; }
    .site-footer { flex-direction: column; }
  }

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

@layer utilities {
  .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;
  }
}
