:root {
  --blue: #34a8ff;
  --blue-dark: #1166c7;
  --yellow: #ffd84d;
  --green: #43d17a;
  --green-dark: #12925d;
  --orange: #ff9e3d;
  --pink: #ff73a6;
  --ink: #12304d;
  --muted: #52708d;
  --shadow: 0 18px 44px rgba(17, 102, 199, .16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 216, 77, .5), transparent 18rem),
    radial-gradient(circle at 88% 10%, rgba(67, 209, 122, .35), transparent 16rem),
    linear-gradient(180deg, #dbf4ff 0%, #f8fdff 45%, #fff8df 100%);
}

button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

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

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--blue-dark);
  background: linear-gradient(145deg, var(--yellow), #fff3a3);
  box-shadow: inset 0 -6px 0 rgba(255, 158, 61, .25), 0 10px 24px rgba(255, 158, 61, .22);
  font-size: 30px;
  font-weight: 1000;
}

.brand h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 36px);
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p, .tip {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 10px 28px rgba(17, 102, 199, .12);
}

.tab {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: transparent;
  font-weight: 900;
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 8px 18px rgba(52, 168, 255, .26);
}

.view { display: none; }
.view.active { display: block; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 350px;
  gap: 18px;
  align-items: stretch;
}

.learn-panel, .side-panel, .library-panel {
  border: 2px solid rgba(52, 168, 255, .16);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
}

.learn-panel {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  padding: clamp(18px, 3vw, 34px);
}

.learn-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(52, 168, 255, .12), transparent 34%),
    radial-gradient(circle at 86% 18%, rgba(255, 216, 77, .45), transparent 11rem);
  pointer-events: none;
}

.sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute;
  width: 118px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  animation: drift 12s ease-in-out infinite alternate;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  bottom: 14px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: inherit;
}
.cloud::before { left: 20px; }
.cloud::after { right: 18px; width: 56px; height: 56px; }
.cloud.one { top: 28px; left: 40px; }
.cloud.two { right: 70px; top: 74px; transform: scale(.72); animation-delay: -4s; opacity: .76; }

.book-tools {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.book-tools label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 900;
}

.book-tools select, .filters input, .filters select, .goal-row select {
  min-height: 42px;
  border: 2px solid #ccecff;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}

.study-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 18px;
  align-items: center;
  min-height: 350px;
}

.word-stage { display: grid; gap: 12px; align-content: center; min-width: 0; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #e4f5ff;
  font-weight: 900;
  font-size: 14px;
}
.badge.yellow { color: #8b5b00; background: #fff0a8; }

.phonetic {
  margin: 0;
  color: var(--green-dark);
  font-size: clamp(24px, 3.5vw, 38px);
  font-weight: 1000;
}

.word {
  margin: 0;
  color: var(--blue-dark);
  font-size: clamp(58px, 10vw, 108px);
  line-height: .92;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.meaning {
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 1000;
}

.media-stack { display: grid; gap: 12px; }

.picture {
  min-height: 210px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .9), transparent 6rem),
    linear-gradient(160deg, #dff6ff, #fff4b9 55%, #defbdd);
  border: 2px solid rgba(255, 216, 77, .55);
}

.picture span {
  font-size: 96px;
  filter: drop-shadow(0 10px 0 rgba(18, 48, 77, .08));
  animation: hop 2s ease-in-out infinite;
}

.mini-video {
  position: relative;
  min-height: 86px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #aee7ff, #f9fdff 62%, #a8edbd 63%);
  border: 2px solid rgba(67, 209, 122, .24);
}

.motion-dot {
  position: absolute;
  left: 14px;
  bottom: 20px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: inset 0 -6px 0 rgba(255, 158, 61, .3);
  animation: travel 3.2s ease-in-out infinite;
}

.motion-word {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #fff;
  font-weight: 1000;
}

.controls {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.big-btn, .small-btn {
  min-height: 62px;
  border-radius: 8px;
  color: #fff;
  font-weight: 1000;
  font-size: 19px;
  box-shadow: 0 8px 0 rgba(18, 48, 77, .14), 0 18px 24px rgba(18, 48, 77, .12);
  transition: transform .15s ease, box-shadow .15s ease;
}
.big-btn:active, .small-btn:active {
  transform: translateY(5px) scale(.99);
  box-shadow: 0 3px 0 rgba(18, 48, 77, .14), 0 8px 14px rgba(18, 48, 77, .1);
}
.speak { background: linear-gradient(180deg, var(--orange), #ff7a2d); }
.next, .blue { background: linear-gradient(180deg, var(--blue), #1885ef); }
.learned, .green { background: linear-gradient(180deg, var(--green), var(--green-dark)); }

.sentence-panel {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 2px solid rgba(52, 168, 255, .12);
  background: rgba(255, 255, 255, .78);
}
.panel-title, .library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-title h2, .library-head h2, .progress-card h2, .practice h2 {
  margin: 0;
  font-size: 22px;
}
.small-btn {
  min-height: 44px;
  padding: 0 14px;
  background: var(--blue);
  font-size: 15px;
}
.sentence-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.sentence {
  display: grid;
  gap: 7px;
  min-height: 118px;
  padding: 12px;
  border: 2px solid rgba(52, 168, 255, .12);
  border-radius: 8px;
  background: #f8fcff;
}
.sentence strong { color: var(--blue-dark); font-size: 17px; }
.sentence span { color: var(--muted); font-weight: 800; }
.sentence button {
  justify-self: start;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.side-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.progress-card, .practice {
  padding: 16px;
  border-radius: 8px;
  background: #f4fbff;
  border: 2px solid rgba(52, 168, 255, .14);
}
.practice {
  background: #fff9df;
  border-color: rgba(255, 216, 77, .42);
}

.today-number {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--green-dark);
  font-weight: 1000;
}
.today-number strong { font-size: 58px; line-height: .9; }

.meter {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #dff1ff;
}
.meter span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  transition: width .35s ease;
}

.goal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 900;
}

.learned-list {
  display: grid;
  gap: 8px;
  max-height: 122px;
  overflow: auto;
  margin-top: 12px;
}
.learned-item {
  display: grid;
  gap: 2px;
  padding: 9px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid rgba(52, 168, 255, .12);
}

.practice-word {
  min-height: 84px;
  display: grid;
  place-items: center;
  margin: 12px 0;
  border-radius: 8px;
  color: var(--blue-dark);
  background: rgba(255, 255, 255, .78);
  font-size: 25px;
  font-weight: 1000;
  text-align: center;
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.answer {
  min-height: 50px;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  border: 2px solid rgba(255, 158, 61, .28);
  font-weight: 1000;
}
.answer.correct { color: #fff; background: var(--green); border-color: var(--green); transform: scale(1.04); }
.answer.wrong { color: #fff; background: var(--pink); border-color: var(--pink); animation: shake .22s ease; }

.mini-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.stars {
  margin-top: 10px;
  color: #8b5b00;
  font-weight: 1000;
}

.library-panel { padding: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input { min-width: 260px; }
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 220px);
  min-height: 430px;
  overflow: auto;
}
.word-chip {
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid rgba(52, 168, 255, .12);
  background: #f8fcff;
  text-align: left;
}
.word-chip strong { color: var(--blue-dark); font-size: 21px; }
.word-chip small, .learned-item small { color: var(--muted); font-weight: 800; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  min-width: min(420px, calc(100% - 36px));
  padding: 14px 18px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: 0 18px 40px rgba(18, 48, 77, .22);
  text-align: center;
  font-weight: 1000;
  transform: translate(-50%, 110px);
  transition: transform .25s ease;
}
.toast.show { transform: translate(-50%, 0); }

@keyframes hop { 50% { transform: translateY(-8px) scale(1.04); } }
@keyframes drift { to { transform: translateX(38px); } }
@keyframes travel {
  0%, 100% { transform: translateX(0) translateY(0); }
  45% { transform: translateX(130px) translateY(-18px); }
  70% { transform: translateX(76px) translateY(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-6px); }
  70% { transform: translateX(6px); }
}

@media (max-width: 900px) {
  .topbar, .library-head, .panel-title { align-items: stretch; flex-direction: column; }
  .mode-tabs { width: 100%; }
  .tab { flex: 1; padding: 0 10px; }
  .hero-grid, .study-card, .book-tools, .sentence-list { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr; }
  .filters input, .filters select { width: 100%; min-width: 0; }
}
