:root {
  --ink: #17212b;
  --muted: #647181;
  --line: #dbe4ed;
  --soft: #f4f7fb;
  --blue: #2563eb;
  --green: #0f9f6e;
  --red: #dc3f42;
  --yellow: #f4b740;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--blue);
  color: var(--white);
  font-weight: 900;
  font-size: 13px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.score-pill {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  font-weight: 900;
}

.app-shell {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
}

.date-panel {
  min-width: 0;
  padding: 30px;
  background: var(--white);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.panel-head h1,
.lesson-hero h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.date-list {
  display: grid;
  gap: 10px;
  margin-top: 28px;
  min-width: 0;
  max-width: 100%;
}

.date-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.date-button.active {
  border-color: var(--blue);
  background: #edf4ff;
}

.date-button strong,
.date-button span {
  display: block;
  min-width: 0;
}

.date-button span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.date-score {
  white-space: nowrap;
  color: var(--blue);
  font-weight: 900;
}

.task-panel {
  min-width: 0;
  padding: clamp(18px, 4vw, 48px);
}

.lesson-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding: clamp(22px, 4vw, 38px);
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--line);
}

.lesson-hero p:not(.eyebrow) {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}

.steps {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  overflow-x: auto;
  padding-bottom: 4px;
  max-width: 100%;
}

.step-tab {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  cursor: pointer;
  font-weight: 800;
}

.step-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

.task-card {
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}

.task-title {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.1;
}

.task-note {
  margin: 0 0 24px;
  color: var(--muted);
}

.items {
  display: grid;
  gap: 14px;
}

.item {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, .8fr);
  gap: 12px;
  align-items: center;
}

.word {
  min-width: 0;
  font-weight: 900;
  overflow-wrap: anywhere;
}

input,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--white);
  color: var(--ink);
}

textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.5;
}

.feedback {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.feedback.good {
  color: var(--green);
  font-weight: 800;
}

.feedback.bad {
  color: var(--red);
  font-weight: 800;
}

.task-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 900;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--white);
}

.ghost-button {
  background: var(--white);
  color: var(--ink);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.result-box {
  padding: 16px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.result-box strong {
  display: block;
  font-size: 26px;
}

.grade {
  margin-top: 24px;
  padding: 22px;
  border-radius: 10px;
  background: #edf4ff;
  border: 1px solid #bad2ff;
}

.grade strong {
  display: block;
  font-size: 36px;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .topbar {
    min-height: 66px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand small {
    display: none;
  }

  .score-pill {
    padding: 8px 10px;
    font-size: 14px;
  }

  .date-panel {
    position: sticky;
    top: 66px;
    z-index: 9;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-head {
    display: none;
  }

  .date-list {
    display: flex;
    gap: 10px;
    margin-top: 0;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    max-width: calc(100vw - 28px);
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .date-button {
    min-width: min(210px, 78vw);
    scroll-snap-align: start;
  }

  .task-panel {
    min-width: 0;
    padding: 14px;
  }

  .lesson-hero {
    padding: 18px;
  }

  .lesson-hero h2 {
    font-size: 30px;
    line-height: 1.05;
  }

  .lesson-hero p:not(.eyebrow) {
    overflow-wrap: anywhere;
  }

  .lesson-hero,
  .item-row,
  .task-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .steps {
    margin: 12px -14px 14px;
    padding: 0 14px 6px;
    max-width: 100vw;
  }

  .step-tab {
    padding: 10px 12px;
    font-size: 14px;
  }

  .task-card {
    padding: 16px;
  }

  .task-title {
    font-size: 24px;
  }

  .item {
    padding: 13px;
  }

  input,
  textarea {
    min-height: 46px;
    font-size: 16px;
  }

  .task-actions {
    position: sticky;
    bottom: 0;
    margin: 18px -16px -16px;
    padding: 12px 16px;
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
