:root {
  --ink: #1d2530;
  --muted: #657386;
  --line: #d8e0e8;
  --panel: #ffffff;
  --page: #f5f7fa;
  --accent: #11645b;
  --accent-strong: #0c4b44;
  --accent-soft: #dcefeb;
  --warm: #f4b35f;
  --danger: #a84040;
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

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

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

.secondary {
  background: var(--warm);
  color: #2b2115;
}

.ghost {
  background: #e9eef4;
  color: var(--ink);
}

.danger {
  color: var(--danger);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.kicker,
.subtitle,
.meta-line,
.tiny {
  margin: 0;
  color: var(--muted);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.45rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

h3 span {
  color: var(--muted);
  font-weight: 700;
}

.actions,
.submit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions {
  flex-shrink: 0;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 920px);
  gap: 28px;
  align-items: start;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 32px) 64px;
}

.side {
  position: sticky;
  top: 94px;
  display: grid;
  gap: 18px;
}

.progress-wrap,
.panel,
.task {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.progress-wrap {
  padding: 16px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebf0;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

#autosaveState {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-nav,
.section-nav {
  display: grid;
  gap: 8px;
}

.section-nav a {
  display: block;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
  border: 1px solid var(--line);
}

.section-nav a:hover {
  border-color: var(--accent);
}

.form {
  display: grid;
  gap: 26px;
}

.panel {
  padding: clamp(18px, 3vw, 30px);
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 28px;
}

.identity-fields,
.short-list {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

label span,
.match-head {
  color: #314050;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c9d4df;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  min-height: 46px;
}

input:focus,
textarea:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.level {
  display: grid;
  gap: 16px;
}

.level-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 10px;
}

.level-head span {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.level-head h2 {
  margin: 0;
}

.task {
  padding: clamp(16px, 2.5vw, 24px);
}

.task p:last-child {
  margin-bottom: 0;
}

.wordbank,
.hint,
.source-text {
  border-left: 4px solid var(--accent);
  background: #eef6f4;
  padding: 12px 14px;
  border-radius: 0 6px 6px 0;
}

.source-text {
  border-color: var(--warm);
  background: #fff6e8;
}

.match-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) minmax(92px, 0.5fr) minmax(130px, 1fr);
  gap: 10px;
  align-items: center;
}

.match-grid input {
  text-transform: uppercase;
}

.match-head {
  font-weight: 800;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.short-list label {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  align-items: center;
}

.short-list label:has(textarea) {
  grid-template-columns: 1fr;
}

.submit-panel {
  display: grid;
  gap: 10px;
}

.answer-preview {
  margin-top: 10px;
}

.answer-preview textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

@media (max-width: 880px) {
  .topbar,
  .layout,
  .intro-grid,
  .short-list label {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    display: grid;
  }

  .layout {
    display: grid;
    padding-top: 18px;
  }

  .side {
    position: static;
    order: -1;
  }

  .section-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .section-nav a {
    text-align: center;
  }

  .match-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .match-head {
    display: none;
  }

  .match-grid input {
    margin-bottom: 8px;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .brand-mark {
    width: 46px;
  }

  .actions button,
  .submit-actions button {
    width: 100%;
  }

  .section-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
