:root {
  --blue: #176bde;
  --blue-deep: #0f4fa9;
  --blue-soft: #e6f0ff;
  --yellow: #ffc73b;
  --yellow-soft: #fff4cf;
  --green: #25a56a;
  --green-soft: #e2f7ec;
  --red: #d94b45;
  --red-soft: #fde8e6;
  --ink: #12233b;
  --muted: #708198;
  --line: #dce5f0;
  --paper: #f4f7fc;
  --white: #fff;
  --shadow: 0 12px 34px rgba(25, 62, 108, .1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(23, 107, 222, .10), transparent 28rem),
    radial-gradient(circle at 90% 8%, rgba(255, 199, 59, .13), transparent 24rem),
    var(--paper);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }
button { color: inherit; }
img { max-width: 100%; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  min-height: 68px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 8px 22px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid rgba(205, 218, 234, .9);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-self: start;
  gap: 10px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 11px; }
.brand span, .brand strong, .brand small { display: block; }
.brand strong { color: var(--ink); font-size: 17px; line-height: 1.2; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.desktop-nav {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #edf2f8;
  border-radius: 10px;
}

.desktop-nav button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  color: #586a81;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.desktop-nav button svg { width: 16px; height: 16px; }
.desktop-nav button.active { color: #fff; background: var(--blue); box-shadow: 0 5px 14px rgba(23, 107, 222, .25); }

.header-stats {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.header-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  color: #687a91;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 10px;
}

.header-stats svg { width: 14px; height: 14px; color: var(--yellow); }
.header-stats span:first-child svg { color: #f46a38; }
.header-stats b { color: var(--ink); font-size: 12px; }

.app-view {
  width: min(1180px, 100%);
  min-height: calc(100vh - 68px);
  margin: 0 auto;
  padding: 24px 22px 100px;
}

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

.page-head h1 { margin: 0; font-size: clamp(24px, 3vw, 36px); line-height: 1.18; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.eyebrow { display: block; margin-bottom: 3px; color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: .1em; }

.hero {
  position: relative;
  display: grid;
  min-height: 280px;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr);
  align-items: center;
  gap: 24px;
  margin-bottom: 20px;
  padding: 30px;
  background:
    linear-gradient(115deg, rgba(10, 68, 156, .98), rgba(23, 107, 222, .9)),
    url("assets/exam_start_top_bg.png") center/cover;
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(17, 83, 176, .22);
  overflow: hidden;
}

.hero::after {
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 280px;
  height: 280px;
  background: rgba(255, 255, 255, .08);
  border-radius: 50%;
  content: "";
}

.hero-copy { position: relative; z-index: 1; color: #fff; }
.hero h1 { max-width: 680px; margin: 8px 0 12px; font-size: clamp(30px, 4.8vw, 52px); line-height: 1.08; }
.hero p { max-width: 660px; margin: 0; color: #dce9ff; font-size: 14px; }
.hero .eyebrow { color: #ffe27b; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button svg { width: 17px; height: 17px; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 8px 18px rgba(23, 107, 222, .24); }
.button.primary:hover { background: var(--blue-deep); }
.button.yellow { color: #563a00; background: var(--yellow); border-color: var(--yellow); }
.button.ghost { color: #dce9ff; background: rgba(255, 255, 255, .11); border-color: rgba(255, 255, 255, .24); }
.button.danger { color: var(--red); border-color: #efbfbc; }
.button.small { min-height: 36px; padding: 0 11px; font-size: 11px; }

.hero-progress {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  align-self: stretch;
}

.progress-ring {
  display: grid;
  width: 176px;
  height: 176px;
  place-items: center;
  background: conic-gradient(var(--yellow) var(--progress, 0deg), rgba(255,255,255,.18) 0);
  border-radius: 50%;
}

.progress-ring-inner {
  display: grid;
  width: 138px;
  height: 138px;
  place-items: center;
  align-content: center;
  color: #fff;
  background: rgba(13, 72, 158, .94);
  border-radius: 50%;
  text-align: center;
}

.progress-ring strong { font-size: 34px; line-height: 1; }
.progress-ring span { margin-top: 5px; color: #dce9ff; font-size: 11px; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.quick-card {
  min-width: 0;
  padding: 17px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}

.quick-card:hover { transform: translateY(-2px); border-color: #aac8f5; }
.quick-icon {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  margin-bottom: 11px;
  border-radius: 12px;
}

.quick-icon svg { width: 23px; height: 23px; }
.quick-card:nth-child(1) .quick-icon { color: var(--blue); background: var(--blue-soft); }
.quick-card:nth-child(2) .quick-icon { color: #8b5b00; background: var(--yellow-soft); }
.quick-card:nth-child(3) .quick-icon { color: var(--green); background: var(--green-soft); }
.quick-card:nth-child(4) .quick-icon { color: var(--red); background: var(--red-soft); }
.quick-card strong, .quick-card span { display: block; }
.quick-card strong { font-size: 15px; }
.quick-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.section-block {
  margin-bottom: 20px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 19px; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.word-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.word-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 13px;
  background: #f8fafe;
  border: 1px solid #e1e9f4;
  border-radius: 11px;
}

.word-card strong { display: block; overflow: hidden; font-size: 17px; text-overflow: ellipsis; }
.word-card small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.word-card .speak { width: 38px; height: 38px; padding: 0; border-radius: 50%; }
.word-card .speak svg { width: 18px; }

.study-shell {
  display: grid;
  min-height: calc(100vh - 190px);
  place-items: center;
}

.study-card {
  width: min(680px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(22, 55, 96, .13);
  text-align: center;
}

.study-progress { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.study-progress b { color: var(--blue); }
.study-word { margin: 32px 0 6px; color: var(--ink); font-size: clamp(40px, 9vw, 74px); font-weight: 850; line-height: 1.08; word-break: break-word; }
.study-phonetic { color: var(--muted); font-size: 16px; }
.study-meaning { margin: 18px 0 26px; color: #475c75; font-size: 20px; }
.speak-main {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  margin: 0 auto 24px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 12px 28px rgba(23, 107, 222, .28);
  cursor: pointer;
}
.speak-main svg { width: 34px; height: 34px; }
.study-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.practice-card {
  width: min(760px, 100%);
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(22, 55, 96, .13);
}
.practice-prompt { margin-bottom: 18px; text-align: center; }
.practice-prompt strong { display: block; font-size: 28px; }
.practice-prompt span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.spelling-input {
  width: 100%;
  min-height: 62px;
  padding: 9px 16px;
  color: var(--ink);
  background: #f6f9fd;
  border: 2px solid #d2e0f2;
  border-radius: 11px;
  outline: 0;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .04em;
}
.spelling-input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(23, 107, 222, .10); }
.answer-feedback { min-height: 28px; margin: 12px 0; text-align: center; font-size: 13px; font-weight: 700; }
.answer-feedback.ok { color: var(--green); }
.answer-feedback.err { color: var(--red); }
.practice-actions { display: flex; justify-content: center; gap: 9px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.option {
  min-height: 58px;
  padding: 8px 12px;
  background: #f7f9fd;
  border: 2px solid #dce6f2;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 750;
}
.option:hover { border-color: #8bb6f0; }
.option.correct { color: #0d7143; background: var(--green-soft); border-color: #76c79d; }
.option.wrong { color: #a82f2a; background: var(--red-soft); border-color: #e89a96; }
.option:disabled { cursor: default; }

.wrong-list { display: grid; gap: 9px; }
.wrong-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: #fbfcfe; border: 1px solid #e0e7f1; border-radius: 10px; }
.wrong-item strong { display: block; font-size: 16px; }
.wrong-item span { color: var(--muted); font-size: 10px; }
.empty { padding: 36px 18px; color: var(--muted); text-align: center; font-size: 12px; }

.library-toolbar { display: flex; gap: 9px; margin-bottom: 14px; }
.library-toolbar input { flex: 1; min-width: 0; }
.library-toolbar select { width: 130px; }
input, select {
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 107, 222, .10); }

.toast {
  position: fixed;
  z-index: 60;
  right: 18px;
  bottom: 88px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 12px;
}
.toast.error { background: var(--red); }

.mobile-nav { display: none; }

@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr auto; padding: 8px 14px; }
  .desktop-nav { display: none; }
  .header-stats span { padding: 6px 7px; }
  .app-view { padding: 16px 14px 100px; }
  .hero { grid-template-columns: 1fr; padding: 24px; }
  .hero-progress { display: none; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .word-grid { grid-template-columns: 1fr 1fr; }
  .mobile-nav {
    position: fixed;
    z-index: 40;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: 0 12px 36px rgba(20, 48, 84, .18);
    backdrop-filter: blur(14px);
  }
  .mobile-nav button { display: grid; min-height: 49px; place-items: center; align-content: center; gap: 2px; color: #728299; background: transparent; border: 0; border-radius: 10px; font-size: 9px; }
  .mobile-nav button svg { width: 19px; height: 19px; }
  .mobile-nav button.active { color: var(--blue); background: var(--blue-soft); }
}

@media (max-width: 620px) {
  .brand img { width: 38px; height: 38px; }
  .brand strong { font-size: 15px; }
  .brand small { display: none; }
  .header-stats span { font-size: 9px; }
  .header-stats svg { display: none; }
  .page-head { display: block; }
  .page-head .button { margin-top: 12px; }
  .hero { min-height: 340px; align-items: end; padding: 22px 18px; }
  .hero h1 { font-size: 34px; }
  .hero-actions { display: grid; }
  .hero-actions .button { width: 100%; }
  .quick-grid, .word-grid { grid-template-columns: 1fr; }
  .section-block { padding: 15px; }
  .study-card, .practice-card { padding: 19px; }
  .study-word { margin-top: 24px; font-size: 46px; }
  .study-actions { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .library-toolbar { display: grid; }
  .library-toolbar select { width: 100%; }
  .wrong-item { display: block; }
  .wrong-item .button { margin-top: 9px; }
}
