:root {
  --ink: #142231;
  --muted: #607285;
  --line: #d8e2eb;
  --soft: #eef6fb;
  --soft-2: #f7fafc;
  --blue: #1f7891;
  --blue-dark: #15566c;
  --green: #218657;
  --red: #d84a4a;
  --gold: #c8912b;
  --white: #fff;
  --shadow: 0 14px 36px rgba(21, 52, 72, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f4f9fc 0%, #eef4f8 42%, #f7f9fb 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
  filter: grayscale(.15);
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px 18px 98px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 7vw, 54px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: 26px;
}

h3 {
  margin-bottom: 8px;
  font-size: 20px;
}

.subtitle,
.hint,
.small {
  color: var(--muted);
  line-height: 1.6;
}

.date-pill,
.badge {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #dff0f8;
  font-weight: 800;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.hero-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px;
  margin-bottom: 14px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.panel {
  padding: 18px;
  margin: 14px 0;
}

.sticky-panel {
  position: sticky;
  top: 0;
  z-index: 4;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.primary,
.secondary,
.upload-btn {
  min-height: 46px;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 850;
}

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

.secondary,
.upload-btn {
  color: var(--blue-dark);
  background: #e6f1f7;
  border: 1px solid #cfe0eb;
}

.danger {
  color: #9f3131;
  background: #fdeaea;
}

.text-btn {
  color: var(--blue);
  background: transparent;
  font-weight: 850;
}

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

.filters {
  margin-bottom: 12px;
}

.library-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  border-radius: 16px;
  padding: 6px;
  background: #e8f1f6;
}

.library-switch button {
  min-height: 44px;
  border-radius: 12px;
  color: var(--blue-dark);
  background: transparent;
  font-weight: 900;
}

.library-switch button.active {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(31, 120, 145, .2);
}

.library-switch span {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 24px;
  min-height: 24px;
  margin-left: 4px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #fff;
  font-size: 12px;
}

.library-subpage {
  display: none;
}

.filters select,
.filters input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: var(--white);
}

.task-list,
.qa-list,
.queue-list,
.task-history,
.daily-log,
.study-calendar {
  display: grid;
  gap: 12px;
}

.task-card,
.qa-card,
.queue-card,
.log-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--soft-2);
}

.log-card.done,
.day-task-detail.done {
  border-color: rgba(33, 134, 87, .45);
  background: #f1fbf5;
}

.chip.success {
  color: #fff;
  background: var(--green);
}

.bilingual-task-card {
  display: grid;
  gap: 8px;
}

.bilingual-lines {
  display: grid;
  gap: 6px;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.bilingual-lines p {
  margin: 0;
  line-height: 1.55;
}

.bilingual-lines b {
  color: var(--blue-dark);
}

.day-detail-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft-2);
}

.day-detail-card summary {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}

.day-detail-card summary::-webkit-details-marker {
  display: none;
}

.day-detail-card summary span {
  color: var(--ink);
  font-weight: 900;
}

.day-detail-card summary em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
}

.day-detail-card[open] summary {
  border-bottom: 1px solid var(--line);
  background: #eaf6fb;
}

.day-detail-body {
  display: grid;
  gap: 16px;
  padding: 14px;
}

.day-detail-body h4 {
  margin: 0 0 8px;
  color: var(--blue-dark);
}

.selected-qa-mini,
.day-task-detail,
.performance-box {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.selected-qa-mini p,
.performance-box p {
  margin: 0;
  line-height: 1.55;
}

.sample-mini {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.sample-mini > div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  border-radius: 12px;
  padding: 8px;
  background: #f6fbff;
}

.sample-mini span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.sample-mini p {
  grid-column: 2;
  margin: 0;
  line-height: 1.5;
}

.task-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--soft-2);
}

.task-strip.done {
  border-color: rgba(33, 134, 87, .45);
  background: #edf8f2;
}

.task-strip-main {
  min-width: 0;
}

.task-strip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.task-strip-main p {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
}

.task-strip-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.task-strip-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.task-strip-actions .done-btn,
.hint-toggle {
  min-height: 40px;
  border-radius: 12px;
  padding: 9px 13px;
  font-weight: 850;
  white-space: nowrap;
}

.hint-toggle {
  color: var(--blue-dark);
  background: #e3f1f8;
}

.small-action {
  min-height: 40px;
  border-radius: 12px;
  padding: 9px 13px;
  font-weight: 850;
  white-space: nowrap;
}

.task-strip-actions .done-btn {
  color: #fff;
  background: var(--green);
}

.task-hint-panel {
  display: none;
  grid-column: 1 / -1;
}

.task-hint-panel.open {
  display: block;
}

.qa-card.selected-qa {
  border-color: rgba(33, 134, 87, .5);
  background: #edf8f2;
}

.qa-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--soft-2);
}

.qa-strip.selected-qa {
  border-color: rgba(33, 134, 87, .5);
  background: #edf8f2;
}

.qa-strip-main {
  min-width: 0;
}

.qa-strip-main p {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
}

.qa-strip-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.qa-strip-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qa-select {
  display: inline-grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  margin: 4px 0 12px;
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--blue-dark);
  background: #e3f1f8;
  font-weight: 850;
}

.qa-select.compact {
  min-height: 40px;
  margin: 0;
  padding: 9px 12px;
  white-space: nowrap;
}

.qa-select input {
  width: 18px;
  height: 18px;
}

.qa-answer-preview {
  display: none;
  grid-column: 1 / -1;
  gap: 8px;
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  background: #f8fbfd;
  border: 1px solid #dfeaf2;
}

.qa-answer-preview.open {
  display: grid;
}

.qa-answer-preview p {
  margin: 0;
  line-height: 1.6;
}

.task-card.done {
  border-color: rgba(33, 134, 87, .45);
  background: #edf8f2;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--blue-dark);
  background: #dff0f8;
  font-size: 12px;
  font-weight: 800;
}

.chip.green {
  color: #17603d;
  background: #dff5e9;
}

.chip.gold {
  color: #7a5414;
  background: #fff0cf;
}

.question-en {
  font-size: 17px;
  font-weight: 850;
  line-height: 1.45;
}

.question-zh,
.answer-zh,
.target-line {
  color: #315267;
  line-height: 1.55;
}

.target-line {
  white-space: pre-line;
}

.answer-guide,
.sample-answer {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  background: #edf7fb;
  border: 1px solid #cfe5f0;
}

.hint-question {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  background: #f8fbfd;
  border: 1px solid #dfeaf2;
}

.hint-question p {
  margin: 6px 0 0;
  color: #315267;
  line-height: 1.55;
}

.answer-guide p {
  margin: 6px 0 0;
  color: #315267;
  line-height: 1.55;
}

.sample-answer {
  background: #f8fbfd;
}

.sample-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e1edf4;
}

.sample-row span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.sample-row p {
  margin: 0 0 6px;
  line-height: 1.55;
}

.answer-en {
  color: #203142;
  line-height: 1.65;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.actions button {
  min-height: 38px;
  border-radius: 11px;
  padding: 8px 12px;
  color: var(--blue-dark);
  background: #e3f1f8;
  font-weight: 800;
}

.actions button.done-btn {
  color: #fff;
  background: var(--green);
}

.sentence-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.sentence-option {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid #d9e9f1;
  border-radius: 12px;
  background: #f4fbff;
}

.sentence-option.selected {
  border-color: var(--blue);
  background: #e3f4fb;
}

.sentence-option input {
  margin-top: 5px;
}

.sentence-option b {
  display: block;
  margin-bottom: 3px;
}

.sentence-option em {
  display: block;
  color: #557083;
  font-style: normal;
  line-height: 1.45;
}

.prompt-box,
.big-box {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  color: var(--ink);
  background: #fbfdff;
  line-height: 1.6;
}

.big-box {
  min-height: 320px;
}

.diagnosis-result ul {
  padding-left: 20px;
  line-height: 1.7;
}

.score-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(135deg, #e4f8ee, #f8fbfd);
  border: 1px solid #bce7cf;
}

.score-card strong {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 28px;
}

.score-card p {
  margin-bottom: 4px;
  font-weight: 850;
}

.score-card span,
.score-card em {
  display: block;
  color: #315267;
  line-height: 1.5;
  font-style: normal;
}

.score-top-panel {
  margin-bottom: 14px;
}

.score-top-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #f8fbfd, #e3f7ee);
}

.score-big {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 36px;
  font-weight: 950;
  box-shadow: 0 12px 28px rgba(33, 134, 87, .22);
}

.score-big span {
  margin-top: -12px;
  font-size: 14px;
}

.score-big.muted {
  background: #b9c8d2;
}

.score-explain {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.score-explain div {
  border-radius: 14px;
  padding: 12px;
  background: #f8fbfd;
  border: 1px solid #dfeaf2;
}

.score-explain h4 {
  margin: 0 0 6px;
}

.score-explain p {
  margin: 0;
  color: #315267;
  line-height: 1.55;
}

.calendar-title {
  font-size: 18px;
  font-weight: 900;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays span {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.calendar-cell {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 6px;
  color: var(--ink);
  background: #f8fbfd;
  text-align: center;
}

.calendar-cell.empty {
  border-color: transparent;
  background: transparent;
}

.calendar-cell.practised {
  border-color: #9edfbf;
  background: #eaf8f1;
}

.calendar-cell.today {
  outline: 2px solid var(--blue);
}

.calendar-cell .day {
  display: block;
  font-weight: 900;
}

.score-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e4edf3;
}

.score-ring.scored {
  background: conic-gradient(var(--green) calc(var(--score) * 1%), #dfe9ef 0);
}

.score-ring.scored::after,
.score-ring.unscored::after,
.score-ring.empty-ring::after {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f8fbfd;
}

.calendar-cell.practised .score-ring.scored::after,
.calendar-cell.practised .score-ring.unscored::after {
  background: #eaf8f1;
}

.score-ring.unscored {
  border: 3px solid var(--green);
  background: transparent;
}

.score-ring i {
  position: absolute;
  color: var(--green);
  font-size: 14px;
  font-style: normal;
  font-weight: 900;
}

.calendar-cell strong {
  display: block;
  color: var(--green);
  font-size: 13px;
}

.calendar-cell em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.stat {
  border-radius: 14px;
  padding: 14px;
  background: var(--soft);
}

.stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 24px;
}

.upload-btn {
  position: relative;
  text-align: center;
}

.upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.backup-status {
  margin: 12px 0 0;
  border-radius: 14px;
  padding: 11px 13px;
  color: #315267;
  background: #f8fbfd;
  border: 1px solid #dfeaf2;
  line-height: 1.55;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(680px, calc(100% - 24px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 7px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 16px 42px rgba(15, 47, 67, .18);
  backdrop-filter: blur(18px);
}

.nav-btn {
  display: grid;
  gap: 3px;
  justify-items: center;
  border-radius: 16px;
  padding: 8px 4px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 850;
}

.nav-btn span {
  font-size: 20px;
}

.nav-btn.active {
  color: #fff;
  background: var(--blue);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 30;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 34, 49, .92);
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.material-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 28, 42, .48);
  backdrop-filter: blur(6px);
}

.material-modal-card {
  width: min(480px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 35, 52, .22);
}

.material-modal-card h2 {
  margin: 4px 0 10px;
}

.material-modal-card p:not(.eyebrow) {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px 12px 96px;
  }

  .topbar,
  .hero-card,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-grid,
  .filters,
  .stats-grid,
  .score-explain {
    grid-template-columns: 1fr;
  }

  .score-top-card {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions,
  .qa-strip,
  .task-strip {
    grid-template-columns: 1fr;
  }

  .qa-strip-actions,
  .task-strip-actions {
    justify-content: flex-end;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .primary,
  .secondary,
  .upload-btn {
    width: 100%;
  }
}
