:root {
  color-scheme: dark;
  --background: #050505;
  --surface: #0b0b0b;
  --text: #ffffff;
  --secondary: #bbbbbb;
  --border: #222222;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--text);
  border-radius: 0;
  padding: 0.8rem 1.15rem;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.choice:focus-within {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.primary-button {
  background: var(--text);
  color: var(--background);
}

.secondary-button {
  background: transparent;
  color: var(--text);
}

.view {
  width: min(100% - 2rem, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 6rem) 0;
}

.intro-view {
  display: flex;
  max-width: 760px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.eyebrow,
.step-label,
.field-help,
.paper-meta,
.paper-section h3 {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
}

.eyebrow,
.step-label,
.field-help {
  color: var(--secondary);
}

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

h1 {
  max-width: 900px;
  margin-bottom: 1.5rem;
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 7rem);
  font-weight: 400;
  line-height: 0.95;
}

.intro-copy,
.results-header > p:last-child {
  max-width: 700px;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 3vw, 2rem);
  line-height: 1.4;
}

.intro-details {
  max-width: 640px;
  margin: 1rem 0 2rem;
  color: var(--secondary);
  line-height: 1.65;
}

.interview-view {
  display: grid;
  grid-template-rows: auto 1fr;
}

[hidden] {
  display: none !important;
}

.interview-header {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 36%);
  gap: 2rem;
  align-items: start;
}

.progress-track {
  height: 2px;
  margin-top: 0.55rem;
  overflow: hidden;
  background: var(--border);
}

.progress-track span {
  display: block;
  width: 5%;
  height: 100%;
  background: var(--text);
  transition: width 250ms ease;
}

.question-panel {
  display: flex;
  min-height: 70vh;
  flex-direction: column;
  justify-content: center;
}

.question-title {
  max-width: 900px;
  margin-bottom: 2rem;
  font-family: var(--serif);
  font-size: clamp(1rem, 4vw, 3.6rem);
  font-weight: 400;
  line-height: 1.08;
}

.question-description {
  max-width: 700px;
  margin: -0.75rem 0 2rem;
  color: var(--secondary);
  line-height: 1.6;
}

.text-input,
.text-area {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--secondary);
  background: transparent;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.5vw, 2rem);
}

.text-input {
  padding: 0.6rem 0;
}

.text-area {
  min-height: 180px;
  padding: 0.75rem 0;
  resize: vertical;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.choice {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--border);
  padding: 0.8rem 1rem;
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--text);
  background: var(--text);
  color: var(--background);
}

.choice input {
  accent-color: var(--background);
}

.keyword-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.image-preview {
  display: block;
  width: 120px;
  height: 120px;
  margin-top: 1rem;
  border: 1px solid var(--border);
  object-fit: cover;
}

.form-error {
  min-height: 1.5rem;
  margin: 1rem 0 0;
  color: var(--secondary);
}

.question-navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.results-view {
  max-width: 1120px;
}

.results-header {
  margin-bottom: 4rem;
}

.results-header h1 {
  font-size: clamp(2.5rem, 6vw, 5rem);
}

.paper-preview {
  margin-bottom: 3rem;
  padding: clamp(1.25rem, 4vw, 3rem);
  background: #f2f0e9;
  color: #111111;
}

.paper-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #111111;
}

.paper-header h2 {
  margin-bottom: 0.3rem;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, 5rem);
  font-weight: 400;
  line-height: 1;
}

.paper-cover {
  min-height: 260px;
  align-items: start;
}

.paper-cover h2 {
  max-width: 760px;
  margin-top: 1.5rem;
}

.paper-site-title {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.paper-statement {
  max-width: 800px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-style: italic;
  line-height: 1.35;
}

.cover-expand {
  border: 0;
  padding: 0;
  background: transparent;
  color: #55534d;
  font-family: var(--mono);
  font-size: max(0.46cqw, 7px);
  text-decoration: underline;
}

.paper-profile-image {
  width: 120px;
  height: 120px;
  border: 1px solid #111111;
  filter: grayscale(1);
  object-fit: cover;
}

.document-chapter {
  margin-top: 2.5rem;
}

.document-chapter-header {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 1rem;
  align-items: baseline;
  padding-top: 0.65rem;
  border-top: 2px solid #111111;
}

.document-chapter-header span {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.document-chapter-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.65rem, 3.5vw, 2.7rem);
  font-weight: 400;
}

.document-entries {
  margin: 1.25rem 0 0 66px;
}

.document-entry {
  max-width: 820px;
  padding: 1rem 0;
  border-top: 1px solid #aaa79f;
}

.document-entry:first-child {
  border-top: 0;
}

.document-entry h4 {
  margin: 0 0 0.45rem;
  color: #55534d;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.document-entry p,
.document-entry li {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.document-entry p:last-child,
.document-entry ul:last-child {
  margin-bottom: 0;
}

.document-entry ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.document-entry li {
  border: 1px solid #77746d;
  padding: 0.35rem 0.6rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid #99968d;
  border-left: 1px solid #99968d;
}

.paper-section {
  min-width: 0;
  padding: 1.4rem;
  border-right: 1px solid #99968d;
  border-bottom: 1px solid #99968d;
}

.paper-section.wide {
  grid-column: 1 / -1;
}

.paper-section h3 {
  margin: 0 0 0.8rem;
  color: #55534d;
}

.paper-section p,
.paper-section li {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.paper-section p:last-child,
.paper-section ul:last-child {
  margin-bottom: 0;
}

.paper-section ul {
  padding-left: 1.2rem;
}

.paper-subsection h4 {
  margin: 1.2rem 0 0.35rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.markdown-panel {
  margin: 3rem 0;
}

.markdown-panel h2 {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
}

.markdown-panel pre {
  max-height: 500px;
  overflow: auto;
  border: 1px solid var(--border);
  padding: 1.25rem;
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.action-status {
  min-height: 1.5rem;
  margin-top: 1rem;
  color: var(--secondary);
}

/* Paper Zero board: fixed 16:9 composition */
.results-view {
  display: flex;
  width: 100%;
  min-height: 100vh;
  max-width: none;
  align-items: center;
  justify-content: center;
  padding: 0.5vh 0.5vw;
}

.paper-stage {
  position: relative;
  width: min(99vw, 176vh);
}

.paper-preview {
  container-type: inline-size;
  display: grid;
  grid-template-rows: 18% 1fr;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0;
  overflow: hidden;
  padding: 2.1cqw;
}

.paper-cover {
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 0 0 1cqw;
  overflow: hidden;
}

.paper-cover h2 {
  max-width: 72cqw;
  margin: 0.5cqw 0 0.25cqw;
  font-size: 3.35cqw;
  line-height: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-meta {
  font-size: 0.64cqw;
}

.paper-site-title {
  margin: 0 0 0.35cqw;
  font-family: var(--serif);
  font-size: 1.05cqw;
  font-weight: 400;
}

.paper-statement {
  display: block;
  max-width: 75cqw;
  margin: 0;
  overflow: visible;
  font-size: 1.3cqw;
  line-height: 1.2;
}

.cover-expand {
  display: none;
}

.paper-profile-image {
  width: 7.5cqw;
  height: 7.5cqw;
}

.document-board-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.15cqw;
  min-height: 0;
  padding-top: 0.8cqw;
  overflow: hidden;
}

.document-board-column {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 0.55cqw;
}

.document-chapter {
  min-height: 0;
  margin: 0;
}

.document-chapter-header {
  grid-template-columns: 1.7cqw 1fr;
  gap: 0.35cqw;
  padding-top: 0.3cqw;
  border-top-width: 1px;
}

.document-chapter-header span {
  font-size: 0.54cqw;
}

.document-chapter-header h3 {
  font-size: 1.16cqw;
  line-height: 1;
}

.document-entries {
  margin: 0.25cqw 0 0 2.05cqw;
}

.document-entry {
  position: relative;
  max-width: none;
  padding: 0.25cqw 1.8cqw 0.25cqw 0;
}

.document-entry h4 {
  margin: 0 0 0.12cqw;
  font-size: 0.5cqw;
  line-height: 1.15;
}

.document-entry p,
.document-entry li {
  font-size: 0.76cqw;
  line-height: 1.22;
}

.document-entry p.document-entry-content {
  display: block;
  overflow: visible;
}

.document-entry ul.document-entry-content {
  display: flex;
  max-height: none;
  gap: 0.22cqw;
  overflow: visible;
  align-content: flex-start;
}

.document-entry li {
  flex: 0 0 auto;
  padding: 0.14cqw 0.28cqw;
  font-family: var(--sans);
  font-size: 0.57cqw;
}

.entry-expand {
  display: none;
  position: absolute;
  top: 0.25cqw;
  right: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: #55534d;
  font-family: var(--mono);
  font-size: max(0.43cqw, 7px);
  text-decoration: underline;
}

.paper-preview.is-dense .document-board-column {
  gap: 0.35cqw;
}

.paper-preview.is-dense .document-entry {
  padding-top: 0.16cqw;
  padding-bottom: 0.16cqw;
}

.paper-preview.is-dense .document-entry p,
.paper-preview.is-dense .document-entry li {
  font-size: 0.68cqw;
}

.paper-preview.is-overflowing .paper-statement,
.paper-preview.is-overflowing .document-entry p.document-entry-content {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.paper-preview.is-overflowing .document-entry ul.document-entry-content {
  max-height: 3.15cqw;
  overflow: hidden;
}

.paper-preview.is-overflowing .entry-expand,
.paper-preview.is-overflowing .cover-expand {
  display: block;
}

.answer-dialog {
  width: min(90vw, 760px);
  max-height: 80vh;
  border: 1px solid var(--border);
  padding: 1.5rem;
  background: var(--background);
  color: var(--text);
}

.answer-dialog::backdrop {
  background: rgb(0 0 0 / 75%);
}

.answer-dialog-header {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.answer-dialog-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
}

.answer-dialog-content {
  max-height: 55vh;
  overflow: auto;
  padding-top: 1.5rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.answer-dialog-content ul {
  padding-left: 1.25rem;
}

.result-actions {
  position: absolute;
  right: 1.2cqw;
  bottom: 1.1cqw;
  z-index: 3;
  justify-content: flex-end;
  margin: 0;
}

.result-actions button {
  border-color: #111111;
  padding: 0.5cqw 0.75cqw;
  font-size: max(0.62cqw, 9px);
}

.result-actions .secondary-button {
  background: #f2f0e9;
  color: #111111;
}

.result-actions .primary-button {
  background: #111111;
  color: #ffffff;
}

.results-view .action-status {
  position: absolute;
  right: 1.2cqw;
  bottom: 4.1cqw;
  z-index: 3;
  min-height: 0;
  margin: 0;
  color: #55534d;
  font-size: max(0.55cqw, 8px);
}

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

@media (max-width: 700px) {
  .interview-header,
  .choices,
  .keyword-grid {
    grid-template-columns: 1fr;
  }

  .progress-track {
    grid-row: 1;
    grid-column: 1;
    margin-bottom: 1rem;
  }

  .paper-section.wide {
    grid-column: auto;
  }

}

@media print {
  body {
    background: white;
  }

  .results-header,
  .markdown-panel,
  .result-actions,
  .action-status {
    display: none;
  }

  .view,
  .results-view {
    width: 100%;
    min-height: 0;
    padding: 0;
  }

  .paper-preview {
    margin: 0;
  }
}
