:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --ink: #1f2933;
  --muted: #627284;
  --line: #d6e0ea;
  --navy: #0d2b45;
  --navy-soft: #e8f0f7;
  --accent: #087ea4;
  --accent-dark: #075f7d;
  --accent-soft: #dff3fa;
  --warm: #f5a524;
  --warm-soft: #fff4db;
  --warning: #9a5a08;
  --warning-soft: #fff4db;
  --shadow: 0 18px 45px rgba(13, 43, 69, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(13, 43, 69, 0.055) 0%, rgba(244, 247, 251, 0) 260px),
    var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.site-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 4px 26px;
}

.compact-nav {
  padding-bottom: 18px;
}

.brand {
  color: var(--navy);
  font-weight: 900;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--navy);
  box-shadow: 0 6px 18px rgba(13, 43, 69, 0.06);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 32px;
  align-items: center;
  min-height: calc(100vh - 132px);
  padding-bottom: 48px;
}

.hero-copy h1,
.page-heading h1 {
  max-width: 760px;
}

.hero-text,
.page-heading p {
  max-width: 660px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.55;
}

.hero-actions,
.stacked-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.primary-link,
.secondary-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 850;
  text-decoration: none;
}

.primary-link {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-link:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.secondary-link {
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent-dark);
}

.secondary-link:hover {
  background: var(--accent-soft);
}

.hero-preview,
.info-panel,
.library-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-preview {
  position: relative;
  padding: 24px;
}

.preview-kicker,
.library-meta {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.preview-question {
  font-size: 1.35rem;
  line-height: 1.35;
  font-weight: 850;
}

.preview-passage {
  display: grid;
  gap: 10px;
  line-height: 1.55;
}

.preview-passage span:first-child {
  border-radius: 5px;
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
  padding: 6px 7px;
}

.feature-grid,
.library-grid,
.content-workspace {
  display: grid;
  gap: 18px;
}

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

.feature-grid article,
.info-panel,
.library-card {
  padding: 22px;
}

.feature-grid article {
  border-top: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.48);
  padding-top: 18px;
}

.feature-grid p,
.library-card p,
.info-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.page-heading {
  padding: 28px 4px 32px;
}

.illustrated-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 230px);
  gap: 24px;
  align-items: center;
}

.heading-illustration {
  width: 100%;
  max-height: 190px;
  mix-blend-mode: multiply;
  object-fit: contain;
  justify-self: end;
}

.feature-illustration,
.panel-illustration {
  display: block;
  width: 124px;
  height: 92px;
  mix-blend-mode: multiply;
  object-fit: contain;
}

.feature-illustration {
  margin: -4px 0 12px;
}

.panel-illustration {
  float: right;
  margin: -14px -8px 10px 16px;
}

.library-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  background: var(--surface);
}

.filter-button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
}

.filter-button:hover,
.filter-button.is-active {
  background: var(--navy);
  color: #ffffff;
}

.library-table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.library-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.library-table th,
.library-table td {
  border-bottom: 1px solid var(--line);
  padding: 16px;
  text-align: left;
  vertical-align: middle;
}

.library-table th {
  background: var(--navy-soft);
  color: var(--navy);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-table tr:last-child td {
  border-bottom: 0;
}

.passage-title-cell {
  min-width: 280px;
}

.passage-title-cell strong,
.passage-title-cell span {
  display: block;
}

.passage-title-cell span {
  max-width: 460px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.status-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-badge.is-not-started {
  background: var(--surface-strong);
  color: var(--muted);
}

.status-badge.is-started {
  background: var(--warning-soft);
  color: var(--warning);
  box-shadow: inset 3px 0 0 var(--warm);
}

.status-badge.is-finished {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.progress-cell {
  min-width: 190px;
}

.progress-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #18a8c9);
}

.table-action {
  min-height: 38px;
  padding: 0 13px;
}

.empty-state {
  margin: 0;
  padding: 24px;
  color: var(--muted);
}

.content-workspace {
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  align-items: start;
}

.exercise-input {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
  color: var(--ink);
  font: 0.9rem ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.5;
}

.single-action {
  grid-template-columns: 180px;
}

.template-preview {
  margin-top: 14px;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.45;
}

.template-preview:empty {
  display: none;
}

.template-preview.is-valid {
  border: 1px solid rgba(23, 107, 91, 0.35);
  background: var(--accent-soft);
}

.template-preview.is-invalid {
  border: 1px solid rgba(143, 76, 22, 0.3);
  background: var(--warning-soft);
  color: var(--warning);
}

.account-workspace {
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.1fr);
}

.account-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.auth-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

.auth-form input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(8, 126, 164, 0.18);
}

.compact-button {
  min-height: 38px;
  padding: 0 14px;
}

.account-message {
  min-height: 48px;
}

.account-message.is-neutral {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
}

.info-panel code {
  border-radius: 4px;
  background: var(--surface-strong);
  color: var(--navy);
  padding: 1px 4px;
  font-size: 0.9em;
}

.topbar,
.workspace {
  display: grid;
  gap: 18px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  padding: 8px 4px 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  color: var(--navy);
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  color: var(--navy);
  margin-bottom: 0;
  font-size: 1.05rem;
}

.session-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-stats span,
.pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--navy);
  font-size: 0.86rem;
  font-weight: 700;
}

.workspace {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: start;
}

.passage-panel,
.question-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.passage-panel {
  min-height: calc(100vh - 148px);
  padding: 24px;
}

.question-panel {
  position: sticky;
  top: 24px;
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.clear-selection-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.clear-selection-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.clear-selection-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.passage-text {
  display: grid;
  gap: 18px;
  padding-top: 20px;
}

.passage-paragraph {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.78;
}

.sentence {
  display: inline;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 1px 1px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  line-height: inherit;
  text-align: left;
  white-space: normal;
}

.sentence:hover {
  border-color: var(--line);
  background: var(--surface-strong);
}

.sentence.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.sentence.is-answer {
  border-color: rgba(8, 126, 164, 0.65);
}

.sentence:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.question-prompt {
  margin: 8px 0 22px;
  font-size: 1.35rem;
  line-height: 1.35;
  font-weight: 750;
}

.original-question {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
  box-shadow: inset 4px 0 0 var(--navy);
}

.original-question-text {
  margin-bottom: 10px;
  font-weight: 800;
  line-height: 1.4;
}

.answer-choices {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.45;
}

.answer-choices li + li {
  margin-top: 6px;
}

.evidence-label {
  margin: 20px 0 0;
}

.selection-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
  box-shadow: inset 4px 0 0 var(--warm);
}

.selection-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.selected-sentence {
  margin-bottom: 0;
  line-height: 1.45;
}

.selected-sentence.is-empty {
  color: var(--muted);
}

.feedback {
  min-height: 88px;
  margin: 18px 0;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid transparent;
}

.feedback:empty {
  display: none;
}

.feedback p {
  margin: 7px 0 0;
  line-height: 1.45;
}

.feedback.is-correct {
  border-color: rgba(8, 126, 164, 0.35);
  background: var(--accent-soft);
}

.feedback.is-incorrect {
  border-color: rgba(143, 76, 22, 0.3);
  background: var(--warning-soft);
  color: var(--warning);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  cursor: pointer;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--accent-dark);
}

.secondary-button:hover {
  background: var(--accent-soft);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .site-shell {
    padding: 16px;
  }

  .topbar,
  .workspace,
  .hero,
  .feature-grid,
  .content-workspace,
  .illustrated-heading {
    grid-template-columns: 1fr;
  }

  .heading-illustration {
    max-width: 210px;
    justify-self: start;
  }

  .site-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .library-toolbar {
    justify-content: flex-start;
  }

  .segmented-control {
    width: 100%;
    border-radius: 8px;
    flex-wrap: wrap;
  }

  .filter-button {
    flex: 1 1 130px;
  }

  .session-stats {
    justify-content: flex-start;
  }

  .passage-panel {
    min-height: auto;
  }

  .question-panel {
    position: static;
  }
}
