:root {
  color-scheme: light;
  --bg: #f4f8ff;
  --panel: #ffffff;
  --panel-soft: #eef5ff;
  --line: #c9d9ff;
  --text: #183153;
  --muted: #5d728f;
  --brand: #4c7df0;
  --brand-deep: #2d58cb;
  --accent: #ffb84d;
  --good: #1f9d6a;
  --bad: #de5b6d;
  --shadow: 0 12px 32px rgba(53, 88, 160, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, #eef5ff 0%, #f7fbff 48%, #f6f8ff 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

body {
  padding: 20px;
}

.cover-page {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
}

.cover-card {
  width: min(560px, 100%);
  padding: 30px;
  border: 1px solid rgba(201, 217, 255, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.cover-brand {
  margin-bottom: 24px;
}

.cover-login {
  display: grid;
  gap: 12px;
}

.cover-login input {
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
}

button,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(76, 125, 240, 0.24);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-btn,
.icon-btn {
  background: #eff4ff;
  color: var(--brand-deep);
  box-shadow: none;
  border: 1px solid var(--line);
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 20px;
}

.topbar,
.app-shell,
.bank-editor,
.auth-panel {
  max-width: 1240px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(201, 217, 255, 0.82);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

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

.brand h1,
.panel-head h2,
.history-box h3,
.wrong-list-head h3 {
  margin: 0;
}

.brand p,
.eyebrow,
.hint-text,
.editor-help,
.history-box span,
.wrong-list li span {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.pup {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(180deg, #8cb4ff 0%, #4c7df0 100%);
  box-shadow: inset 0 -7px 0 rgba(255, 255, 255, 0.22);
}

.pup .face {
  position: absolute;
  inset: 11px 10px 10px;
  border-radius: 16px;
  background: #fff8eb;
}

.pup .ear {
  position: absolute;
  top: 1px;
  width: 18px;
  height: 22px;
  background: #214aa8;
  border-radius: 50% 50% 45% 45%;
}

.pup .ear.left { left: 7px; transform: rotate(-24deg); }
.pup .ear.right { right: 7px; transform: rotate(24deg); }

.selectors {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 10px;
  align-items: end;
}

.selectors label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

select {
  min-width: 146px;
  padding: 11px 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
}

.dictation-panel,
.stats-panel,
.editor-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(201, 217, 255, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.dictation-panel,
.stats-panel {
  padding: 22px;
}

.check-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #dce7ff;
}

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

.panel-head.compact {
  margin-bottom: 16px;
}

.round-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: #eff4ff;
  color: var(--brand-deep);
  font-size: 13px;
  white-space: nowrap;
}

.progress-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7efff;
  margin-bottom: 18px;
}

.progress-track > div {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand) 0%, #74a3ff 100%);
}

.progress-track span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #0f2d59;
}

.word-stage {
  position: relative;
  min-height: 240px;
  padding: 28px 20px;
  border-radius: 18px;
  border: 1px dashed #b8ccf6;
  background:
    linear-gradient(180deg, #f8fbff 0%, #edf5ff 100%);
  overflow: hidden;
}

.stage-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cloud {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 999px;
}

.cloud.one {
  width: 102px;
  height: 30px;
  top: 24px;
  right: 26px;
}
.cloud.one::before {
  width: 38px;
  height: 38px;
  left: 12px;
  top: -16px;
}
.cloud.one::after {
  width: 46px;
  height: 46px;
  right: 14px;
  top: -20px;
}

.cloud.two {
  width: 72px;
  height: 24px;
  bottom: 28px;
  left: 22px;
}
.cloud.two::before {
  width: 30px;
  height: 30px;
  left: 8px;
  top: -12px;
}
.cloud.two::after {
  width: 34px;
  height: 34px;
  right: 10px;
  top: -14px;
}

.word-prompt {
  position: relative;
  margin: 30px 0 12px;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
  color: #173264;
  letter-spacing: 0;
  word-break: break-word;
}

.hint-text,
.answer-text {
  position: relative;
  margin: 0;
  text-align: center;
}

.hint-text {
  min-height: 24px;
  font-size: 15px;
}

.answer-text {
  min-height: 28px;
  margin-top: 6px;
  font-size: 15px;
  color: var(--brand-deep);
}

.primary-actions,
.mark-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eff4ff;
}

.speed-control .speed-btn {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-deep);
  box-shadow: none;
}

.speed-control .speed-btn.active {
  background: var(--brand);
  color: #fff;
}

.primary-actions button,
.mark-actions button,
.wrong-list-head button,
.editor-actions button,
.checker-actions button {
  min-height: 44px;
}

.camera-btn {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #442d00;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 184, 77, 0.24);
}

.camera-btn input {
  display: none;
}

.checker-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
  gap: 14px;
}

.photo-box {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8ccf6;
  border-radius: 14px;
  background: #f8fbff;
  overflow: hidden;
}

.photo-box img {
  width: 100%;
  height: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
}

.photo-box p,
.status-text {
  color: var(--muted);
}

.ocr-box {
  display: grid;
  gap: 8px;
}

.ocr-box label {
  font-size: 13px;
  color: var(--muted);
}

#ocrText {
  min-height: 150px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

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

.status-text {
  margin: 0;
  font-size: 13px;
}

.check-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: #f7faff;
  border: 1px solid #dce7ff;
}

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

.check-summary span {
  color: var(--muted);
}

.check-result ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.check-result li {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #dce7ff;
}

.check-result li strong {
  display: block;
}

.check-result li span {
  color: var(--muted);
}

.manual-check {
  margin-top: 14px;
}

.manual-word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}

.manual-word {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #dce7ff;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  box-shadow: none;
  text-align: left;
}

.manual-word.selected {
  border-color: #ff8da0;
  background: #fff0f3;
  color: #b22138;
  font-weight: 700;
}

.mark-actions .correct { background: var(--good); }
.mark-actions .wrong { background: var(--bad); }
.mark-actions .neutral { background: #7c8ea8; }

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

.score-grid div {
  padding: 16px 12px;
  text-align: center;
  border-radius: 14px;
  background: var(--panel-soft);
}

.score-grid strong {
  display: block;
  font-size: 28px;
  color: var(--brand-deep);
}

.reward-strip {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0 18px;
  font-size: 28px;
  color: #ffd24d;
  filter: saturate(0.85);
}

.reward-strip span.off {
  color: #e1e8f7;
}

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

.wrong-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.wrong-list li,
.history-box li {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f5f8ff;
  border: 1px solid #dce7ff;
}

.wrong-list li strong {
  display: block;
  margin-bottom: 4px;
}

.wrong-list li.priority,
.check-result li.priority {
  border-color: #ff9bab;
  background: #fff3f5;
}

.wrong-list li.priority strong,
.check-result li.priority strong {
  color: #b22138;
}

.history-box ol {
  margin: 0;
  padding-left: 20px;
}

.history-box li + li {
  margin-top: 8px;
}

.bank-editor {
  margin-top: 18px;
}

.editor-card {
  padding: 22px;
}

.editor-help {
  margin-top: 0;
  line-height: 1.6;
}

#bankTextarea {
  width: 100%;
  min-height: 260px;
  padding: 14px;
  resize: vertical;
  line-height: 1.6;
}

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

.auth-panel {
  margin-top: 18px;
}

.auth-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-form input {
  flex: 1 1 260px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
}

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

  .topbar {
    display: grid;
  }

  .selectors {
    grid-template-columns: 1fr 1fr auto;
  }
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

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

  .app-shell {
    grid-template-columns: 1fr;
  }

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

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

  .panel-head,
  .wrong-list-head {
    flex-direction: column;
    align-items: stretch;
  }
}
