:root {
  --e123-ink: #172033;
  --e123-muted: #66718a;
  --e123-line: #dbe5f6;
  --e123-page: #f8faff;
  --e123-work: #eef4ff;
  --e123-panel: #ffffff;
  --e123-blue: #3b68f2;
  --e123-blue-strong: #2f5be1;
  --e123-green: #d9f5ee;
  --e123-green-mark: #a7e8dc;
  --e123-purple: #d8c8ff;
  --e123-purple-soft: #eee8ff;
  --e123-yellow: #fff0a9;
  --e123-red: #d94d61;
  --e123-red-soft: #fff0f2;
  --e123-shell: min(1480px, calc(100vw - 32px));
  --e123-side: clamp(310px, 24vw, 390px);
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 12px 0 24px;
  background: var(--e123-page);
  color: var(--e123-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.date-panel,
.topbar,
.app-shell,
.app-shell.sidebar-collapsed {
  width: var(--e123-shell) !important;
  max-width: var(--e123-shell) !important;
  margin-right: auto !important;
  margin-left: auto !important;
  transform: none !important;
}

.date-panel,
.app-shell.sidebar-collapsed .date-panel {
  position: relative;
  top: auto;
  z-index: 1;
  display: grid !important;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 58px;
  margin-bottom: 8px;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

.sidebar-toggle,
.app-shell.sidebar-collapsed .sidebar-toggle {
  display: none;
}

.panel-head,
.app-shell.sidebar-collapsed .panel-head {
  display: block;
  min-width: 0;
  padding-left: 2px;
}

.panel-head .eyebrow {
  margin: 0 0 2px;
  color: var(--e123-blue);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-head h1 {
  margin: 0;
  color: var(--e123-ink);
  font-size: 16px;
  font-weight: 620;
  line-height: 1.05;
}

.date-list,
.app-shell.sidebar-collapsed .date-list {
  display: flex;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 2px 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.date-list::-webkit-scrollbar {
  display: none;
}

.date-button {
  width: auto;
  min-width: 150px;
  min-height: 52px;
  flex: 0 0 auto;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--e123-line);
  border-radius: 14px;
  background: var(--e123-panel);
  color: var(--e123-muted);
  box-shadow: none;
}

.date-button strong {
  color: inherit;
  font-size: 17px;
  font-weight: 650;
}

.date-button span span {
  color: inherit;
  font-size: 12px;
  font-weight: 560;
}

.date-score {
  color: inherit;
  font-size: 14px;
  font-weight: 650;
}

.date-button.active {
  border-color: var(--e123-blue);
  background: #edf4ff;
  color: var(--e123-ink);
  box-shadow: inset 0 0 0 1px rgba(59, 104, 242, .18);
}

.date-button.completed {
  border-color: #bfe8de;
  background: var(--e123-green);
  color: var(--e123-ink);
}

.topbar {
  position: relative;
  top: auto;
  display: flex;
  align-items: center;
  min-height: 108px;
  padding: 22px 34px;
  border: 1px solid var(--e123-line);
  border-radius: 24px 24px 0 0;
  background: var(--e123-panel);
  box-shadow: none;
}

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

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 18px;
  background: var(--e123-blue);
  color: #fff;
  font-size: 18px;
  font-weight: 520;
}

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

.brand strong {
  color: var(--e123-ink);
  font-size: 24px;
  font-weight: 620;
  line-height: 1.08;
}

.brand small {
  margin-top: 6px;
  color: var(--e123-muted);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.1;
}

.header-tools,
.header-progress {
  display: flex;
  align-items: center;
}

.header-tools {
  gap: 20px;
}

.header-progress {
  gap: 18px;
}

.header-progress-track {
  width: 190px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eefb;
}

.header-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--e123-blue);
}

.header-progress strong {
  min-width: 110px;
  color: var(--e123-ink);
  font-size: 25px;
  font-weight: 620;
  line-height: 1;
  white-space: nowrap;
}

.user-button {
  width: auto;
  min-width: 60px;
  min-height: 60px;
  padding: 0 18px;
  border: 1px solid var(--e123-line);
  border-radius: 20px;
  background: #fff;
  color: var(--e123-ink);
  font-size: 16px;
  font-weight: 620;
}

.user-button.is-authenticated {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 20px;
  font-size: 0;
}

.app-shell,
.app-shell.sidebar-collapsed {
  display: block;
  height: calc(100vh - 190px);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--e123-line);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  background: var(--e123-panel);
  box-shadow: none;
}

.task-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--e123-side);
  grid-template-areas: "task steps";
  align-items: stretch;
  gap: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: var(--e123-panel);
}

.lesson-hero {
  display: none !important;
}

.task-card {
  grid-area: task;
  height: 100%;
  min-height: 0;
  padding: clamp(34px, 4vh, 48px) clamp(30px, 3vw, 46px) 28px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--e123-work);
  box-shadow: none;
}

.task-card::before {
  display: none;
}

#taskContent,
.task-actions {
  width: min(880px, 100%);
}

.task-title {
  margin: 0 0 10px;
  color: var(--e123-ink);
  font-size: clamp(34px, 2.8vw, 46px);
  font-weight: 560;
  line-height: 1.1;
  letter-spacing: 0;
}

.task-note {
  margin: 0 0 clamp(20px, 2.6vh, 32px);
  color: var(--e123-muted);
  font-size: clamp(18px, 1.35vw, 23px);
  font-weight: 460;
  line-height: 1.35;
}

.focus-card,
.chatgpt-card {
  width: 100%;
  display: grid;
  gap: clamp(16px, 2vh, 24px);
  padding: clamp(24px, 3vh, 34px) clamp(26px, 2.7vw, 38px) 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--e123-panel);
  box-shadow: none;
}

.focus-head,
.task-inline-tools {
  display: flex;
  align-items: center;
}

.focus-head {
  justify-content: space-between;
  gap: 18px;
}

.focus-head .micro-head {
  display: block;
  margin: 0;
  color: var(--e123-muted);
  font-size: clamp(16px, 1.25vw, 20px);
  font-weight: 520;
  text-transform: none;
  letter-spacing: 0;
}

.focus-head .micro-head strong {
  display: none;
}

.task-inline-tools {
  flex: 0 0 auto;
  gap: 12px;
}

.task-inline-tools .listen-button {
  width: 54px;
  height: 54px;
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--e123-line);
  border-radius: 17px;
  background: #fff;
  color: var(--e123-ink);
  font-size: 19px;
  box-shadow: none;
}

.task-inline-tools .lesson-chatgpt-button {
  border-color: transparent;
  background: var(--e123-purple);
}

.prompt-word {
  min-height: clamp(64px, 7vh, 82px);
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border: 0;
  border-radius: 16px;
  background: #e7efff;
  color: var(--e123-ink);
  font-size: clamp(30px, 2.5vw, 40px);
  font-weight: 650;
  line-height: 1.1;
}

.gap-sentence {
  display: block;
  padding: 4px 0 8px;
  border: 0;
  background: transparent;
  color: var(--e123-ink);
  font-size: clamp(28px, 2.4vw, 38px);
  font-weight: 520;
  line-height: 1.28;
}

.gap-blank {
  display: inline-block;
  width: clamp(68px, 5vw, 88px);
  height: .85em;
  margin: 0 11px -3px;
  border-bottom: 4px solid var(--e123-blue);
  vertical-align: baseline;
}

.answer-label {
  margin: 2px 0 -10px;
  color: var(--e123-ink);
  font-size: clamp(17px, 1.3vw, 21px);
  font-weight: 560;
}

input,
textarea {
  min-height: clamp(60px, 6.4vh, 76px);
  padding: 0 24px;
  border: 1px solid var(--e123-line);
  border-radius: 17px;
  background: #f7faff;
  color: var(--e123-ink);
  font-size: clamp(18px, 1.5vw, 24px);
  font-weight: 460;
}

input:focus,
textarea:focus {
  border-color: var(--e123-blue);
  box-shadow: 0 0 0 4px rgba(59, 104, 242, .12);
}

input.answer-correct,
textarea.answer-correct {
  border-color: #74d8bf;
  background: var(--e123-green);
}

input.answer-incorrect,
textarea.answer-incorrect {
  border-color: #f0a5ae;
  background: var(--e123-red-soft);
}

.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-chip {
  min-height: 44px;
  padding: 8px 17px;
  border: 0;
  border-radius: 999px;
  background: #e8f0ff;
  color: var(--e123-ink);
  font-size: clamp(16px, 1.2vw, 19px);
  font-weight: 560;
}

.option-chip:nth-child(2n) {
  background: var(--e123-green);
}

.option-chip:nth-child(3n) {
  background: var(--e123-purple-soft);
}

.option-chip:nth-child(4n) {
  background: var(--e123-yellow);
}

.option-chip.selected {
  box-shadow: inset 0 0 0 2px var(--e123-blue);
}

.feedback {
  min-height: 22px;
  color: var(--e123-muted);
  font-size: 16px;
}

.feedback.good {
  color: #259776;
}

.feedback.bad {
  color: var(--e123-red);
}

.task-actions {
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 18px clamp(26px, 2.7vw, 38px) 24px;
  border: 0;
  border-top: 1px solid var(--e123-line);
  border-radius: 0 0 26px 26px;
  background: var(--e123-panel);
}

.primary-button,
.ghost-button {
  min-height: 54px;
  padding: 0 30px;
  border-radius: 18px;
  font-size: clamp(18px, 1.5vw, 23px);
  font-weight: 520;
}

.primary-button {
  border-color: transparent;
  background: var(--e123-blue);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--e123-blue-strong);
}

.ghost-button {
  border: 1px solid var(--e123-line);
  background: #fff;
  color: var(--e123-ink);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: .5;
}

#prevBtn::before {
  content: "←";
  margin-right: 12px;
}

#nextBtn::after {
  content: "→";
  margin-left: 12px;
}

.steps {
  grid-area: steps;
  position: relative;
  top: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  height: 100%;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: clamp(34px, 5vh, 58px) clamp(20px, 1.7vw, 30px);
  overflow: auto;
  border: 0;
  border-left: 1px solid var(--e123-line);
  border-radius: 0;
  background: var(--e123-panel);
  box-shadow: none;
}

.steps::before {
  content: attr(data-caption);
  display: block;
  margin: 0 10px 20px;
  color: var(--e123-muted);
  font-size: clamp(20px, 1.55vw, 26px);
  font-weight: 460;
}

.step-tab.route-group {
  width: 100%;
  min-height: 86px;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 14px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--e123-muted);
  text-align: left;
}

.step-tab.route-group span {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #edf4ff;
  color: var(--e123-blue);
  font-size: 22px;
  font-weight: 600;
}

.step-tab.route-group small {
  display: block;
  color: inherit;
  line-height: 1.18;
}

.step-tab.route-group small strong,
.step-tab.route-group small em {
  display: block;
  font-style: normal;
}

.step-tab.route-group small strong {
  margin-bottom: 4px;
  color: inherit;
  font-size: clamp(20px, 1.45vw, 25px);
  font-weight: 580;
}

.step-tab.route-group small em {
  color: inherit;
  font-size: clamp(16px, 1.15vw, 20px);
  font-weight: 460;
}

.step-tab.route-group.completed {
  background: var(--e123-green);
  color: var(--e123-ink);
}

.step-tab.route-group.completed span {
  background: var(--e123-green-mark);
  color: var(--e123-ink);
}

.step-tab.route-group.active,
.step-tab.route-group.completed.active {
  background: var(--e123-blue);
  color: #fff;
}

.step-tab.route-group.active span,
.step-tab.route-group.completed.active span {
  background: rgba(255, 255, 255, .2);
  color: #fff;
}

.step-tab.route-group:disabled {
  opacity: .54;
}

.word-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f6f9ff;
}

.word-list strong {
  color: var(--e123-ink);
  font-weight: 600;
}

.word-list span {
  color: var(--e123-muted);
}

@media (max-height: 820px) and (min-width: 981px) {
  body {
    padding-top: 8px;
  }

  .date-panel,
  .app-shell.sidebar-collapsed .date-panel {
    min-height: 50px;
    margin-bottom: 6px;
  }

  .topbar {
    min-height: 92px;
    padding-top: 16px;
    padding-bottom: 16px;
  }

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

  .brand strong {
    font-size: 22px;
  }

  .brand small {
    font-size: 15px;
  }

  .app-shell,
  .app-shell.sidebar-collapsed {
    height: calc(100vh - 156px);
  }

  .task-card {
    padding-top: 28px;
  }

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

  .task-note {
    margin-bottom: 18px;
    font-size: 18px;
  }

  .focus-card,
  .chatgpt-card {
    gap: 13px;
    padding-top: 22px;
  }

  .prompt-word,
  input,
  textarea {
    min-height: 58px;
  }

  .option-chip {
    min-height: 40px;
    font-size: 15px;
  }

  .task-actions {
    padding-top: 14px;
    padding-bottom: 18px;
  }

  .primary-button,
  .ghost-button {
    min-height: 48px;
    font-size: 18px;
  }
}

@media (max-width: 980px) {
  body {
    padding: 0 0 calc(76px + env(safe-area-inset-bottom));
    overflow: auto;
  }

  .date-panel,
  .topbar,
  .app-shell,
  .app-shell.sidebar-collapsed {
    width: 100% !important;
    max-width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .date-panel,
  .app-shell.sidebar-collapsed .date-panel {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
    margin-bottom: 0;
    padding: 8px 10px;
  }

  .panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }

  .topbar {
    min-height: 64px;
    padding: 9px 10px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    font-size: 13px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand small,
  .header-progress-track {
    display: none;
  }

  .header-tools {
    gap: 8px;
  }

  .header-progress strong {
    min-width: auto;
    font-size: 14px;
  }

  .user-button,
  .user-button.is-authenticated {
    width: 52px;
    min-width: 52px;
    max-width: 52px;
    height: 40px;
    min-height: 40px;
    border-radius: 12px;
    font-size: 13px;
  }

  .user-button.is-authenticated {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
  }

  .app-shell,
  .app-shell.sidebar-collapsed {
    height: auto;
    min-height: 0;
  }

  .task-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "steps"
      "task";
    min-height: 0;
  }

  .steps {
    display: flex;
    gap: 8px;
    height: auto;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-left: 0;
    border-bottom: 1px solid var(--e123-line);
  }

  .steps::before {
    display: none;
  }

  .step-tab.route-group {
    width: auto;
    min-width: 122px;
    min-height: 54px;
    flex: 0 0 auto;
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 7px 8px;
  }

  .step-tab.route-group span {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .step-tab.route-group small strong,
  .step-tab.route-group small em {
    font-size: 12px;
  }

  .task-card {
    height: auto;
    min-height: 0;
    padding: 24px 10px;
  }

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

  .task-note {
    margin-bottom: 18px;
    font-size: 17px;
  }

  .focus-card,
  .chatgpt-card {
    gap: 16px;
    padding: 18px 14px 0;
    border-radius: 14px 14px 0 0;
  }

  .focus-head .micro-head {
    font-size: 15px;
  }

  .task-inline-tools .listen-button {
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 12px;
    font-size: 15px;
  }

  .prompt-word,
  input,
  textarea {
    min-height: 58px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 18px;
  }

  .gap-sentence {
    font-size: 24px;
  }

  .gap-blank {
    width: 62px;
    border-bottom-width: 4px;
  }

  .answer-label {
    font-size: 18px;
  }

  .option-grid {
    gap: 8px;
  }

  .option-chip {
    min-height: 42px;
    padding: 8px 14px;
    font-size: 16px;
  }

  .task-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    width: 100%;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--e123-line);
    border-radius: 0;
  }

  .primary-button,
  .ghost-button {
    min-height: 48px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 16px;
  }
}
