:root {
  color-scheme: light;
  --bg: #f4efe7;
  --bg-strong: #efe2cf;
  --ink: #1d1a17;
  --muted: #61574d;
  --line: rgba(61, 47, 32, 0.14);
  --card: rgba(255, 251, 245, 0.82);
  --card-strong: rgba(255, 250, 242, 0.95);
  --accent: #b5512d;
  --accent-deep: #733a23;
  --accent-soft: #f4ceb5;
  --teal: #20656a;
  --teal-soft: #d7eceb;
  --gold: #cf9f39;
  --shadow: 0 22px 60px rgba(64, 38, 19, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --copy-width: 72ch;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(207, 159, 57, 0.28), transparent 32%),
    radial-gradient(circle at top right, rgba(32, 101, 106, 0.16), transparent 26%),
    linear-gradient(180deg, #fbf8f3 0%, var(--bg) 52%, #efe7dc 100%);
}

body,
input,
button,
textarea {
  font: inherit;
}

button,
input,
textarea {
  border-radius: var(--radius-sm);
}

.page-aura {
  position: fixed;
  inset: -12rem auto auto -6rem;
  width: 26rem;
  height: 26rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(181, 81, 45, 0.16) 0%, transparent 72%);
  pointer-events: none;
  filter: blur(8px);
}

.page-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(92, 72, 51, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 72, 51, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 78%);
}

.page-grid span {
  display: none;
}

.hero,
.layout {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
}

.hero {
  display: grid;
  gap: 1.5rem;
  padding: 2rem 0 1rem;
}

.hero-copy,
.panel h2,
.panel h3,
.callout strong,
.session-card h3,
.concept-card strong,
.library-card h3,
.score-number {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.hero-copy {
  padding-top: 1.5rem;
  animation: rise-in 500ms ease-out both;
}

.hero-copy h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.8rem, 7vw, 5.6rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.hero-text {
  max-width: 54ch;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.eyebrow,
.mini-label,
.source-type {
  margin: 0 0 0.55rem;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-actions,
.upload-actions,
.form-actions,
.session-actions,
.session-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-actions {
  margin-top: 1.5rem;
}

.layout {
  display: grid;
  gap: 1rem;
  padding: 0 0 2rem;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--card-strong), var(--card));
  box-shadow: var(--shadow);
  animation: rise-in 600ms ease-out both;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), transparent);
}

.hero-panel {
  align-self: start;
}

.metric-grid,
.core-grid,
.subgrid,
.score-band {
  display: grid;
  gap: 0.85rem;
}

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

.metric-grid article,
.core-card,
.score-band article,
.concept-card,
.library-card,
.stack-card,
.session-card,
.question-card,
.summary-card {
  border: 1px solid rgba(73, 56, 39, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.82);
}

.metric-grid article {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
}

.metric-grid strong {
  font-size: 1.8rem;
}

.metric-grid span,
.muted,
.library-meta,
.choice-help {
  color: var(--muted);
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2,
.section-heading h3,
.panel h3 {
  margin: 0;
  font-size: 1.45rem;
}

.pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 700;
}

.upload-actions {
  margin: 1rem 0;
}

#source-upload {
  position: absolute;
  left: -9999px;
}

.file-button,
button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.file-button,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0.8rem 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: #fff8f1;
}

.secondary-button {
  background: #fff0e6;
  color: var(--accent-deep);
}

.ghost-button,
.file-button {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid rgba(61, 47, 32, 0.12);
}

button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

textarea,
input[type="text"],
input[type="search"] {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(73, 56, 39, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 9rem;
  line-height: 1.55;
}

.textarea-label {
  display: inline-block;
  margin-bottom: 0.55rem;
  font-weight: 700;
}

.form-actions input {
  flex: 1 1 16rem;
}

.core-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.core-card,
.score-band article,
.stack-card,
.summary-card {
  padding: 1rem;
}

.session-root {
  min-height: 20rem;
}

.empty-state {
  padding: 1.1rem;
  border: 1px dashed rgba(73, 56, 39, 0.2);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.48);
}

.session-card {
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
}

.session-meta,
.question-meta,
.library-actions,
.choice-row,
.choice-header,
.confidence-row,
.coverage-row,
.stack-row-top,
.stack-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.question-card {
  padding: 1rem;
}

.question-card h3 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  line-height: 1.4;
}

.choices {
  display: grid;
  gap: 0.75rem;
}

.choice-row {
  align-items: flex-start;
  padding: 0.9rem;
  border: 1px solid rgba(73, 56, 39, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
}

.choice-row input {
  margin-top: 0.2rem;
}

.choice-copy {
  flex: 1;
  display: grid;
  gap: 0.35rem;
}

.confidence-row {
  flex-wrap: wrap;
}

.confidence-row select {
  min-width: 12rem;
}

select {
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(73, 56, 39, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
}

.feedback {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: #fff5ee;
  border: 1px solid rgba(181, 81, 45, 0.18);
}

.feedback.correct {
  background: #edf7f7;
  border-color: rgba(32, 101, 106, 0.2);
}

.feedback strong,
.callout strong,
.concept-card strong,
.library-card h3,
.stack-card strong {
  display: block;
  margin-bottom: 0.35rem;
}

.feedback p,
.concept-card p,
.library-card p,
.core-card p,
.stack-card p,
.callout p {
  margin: 0.35rem 0 0;
  line-height: 1.6;
}

.evidence {
  margin-top: 0.75rem;
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(32, 101, 106, 0.08);
}

.score-band {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.score-band strong {
  font-size: 1.7rem;
}

.subgrid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  margin-top: 1rem;
}

.stack-list,
.concept-list,
.library-list {
  display: grid;
  gap: 0.85rem;
}

.stack-card,
.concept-card,
.library-card {
  padding: 1rem;
}

.coverage-meter,
.mastery-meter {
  width: 100%;
  height: 0.6rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(97, 87, 77, 0.14);
}

.coverage-meter span,
.mastery-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.concept-card details {
  margin-top: 0.65rem;
}

.callout {
  min-height: 100%;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 240, 230, 0.92), rgba(239, 252, 251, 0.92));
}

.library-actions {
  margin-top: 0.85rem;
}

.tiny-button {
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(73, 56, 39, 0.14);
  background: rgba(255, 255, 255, 0.84);
  font-size: 0.88rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 920px) {
  .hero {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    align-items: end;
    padding-top: 2.75rem;
  }

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

  .upload-panel,
  .architecture-panel,
  .session-panel,
  .dashboard-panel,
  .concepts-panel,
  .library-panel {
    grid-column: span 12;
  }

  .upload-panel,
  .architecture-panel {
    grid-column: span 6;
  }

  .session-panel {
    grid-column: span 7;
  }

  .dashboard-panel {
    grid-column: span 5;
  }

  .concepts-panel {
    grid-column: span 7;
  }

  .library-panel {
    grid-column: span 5;
  }
}

@media (max-width: 919px) {
  .hero-copy h1 {
    max-width: 10ch;
  }

  .section-heading {
    flex-direction: column;
  }
}
