:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --ink: #18212b;
  --muted: #667382;
  --line: #d9e1e7;
  --accent: #276b65;
  --accent-2: #c85d42;
  --good: #2e7d55;
  --warn: #b77c18;
  --bad: #b44747;
  --shadow: 0 14px 35px rgba(28, 38, 49, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  background: #17252f;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f3c858;
  color: #17252f;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
}

.brand p {
  margin-top: 4px;
  color: #b8c6cf;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  text-align: left;
  padding: 13px 14px;
  border-radius: 8px;
  background: transparent;
  color: #dce7ed;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.daily-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 5px;
}

.daily-card strong {
  font-size: 42px;
}

.daily-card small,
.daily-card span {
  color: #c7d3db;
}

.main {
  min-width: 0;
  padding: 30px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.toolbar h2,
.toolbar p {
  margin: 0;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.primary-button,
.ghost-button,
.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ghost-button:hover,
.import-button:hover {
  border-color: var(--accent);
}

.import-button input {
  display: none;
}

.search-input {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.review-limit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--muted);
}

.review-limit input {
  width: 72px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 4px;
  color: var(--ink);
  text-align: center;
}

.practice-grid {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px;
}

.import-grid,
.listening-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.paper-list-panel {
  padding: 18px;
  align-self: start;
}

.import-panel,
.listening-player {
  padding: 18px;
}

.large-textarea {
  min-height: 430px;
  line-height: 1.65;
}

.full-input {
  width: 100%;
  margin: 14px 0;
}

.paper-list-panel h3 {
  margin: 0 0 14px;
}

.paper-list {
  display: grid;
  gap: 10px;
}

.paper-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  background: #fff;
}

.paper-item.active {
  border-color: var(--accent);
  background: #edf8f6;
}

.paper-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.reading-panel {
  padding: 22px;
  min-height: 70vh;
}

.paper-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.paper-heading h3 {
  margin: 4px 0 0;
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

.passage-text {
  margin: 22px 0;
  padding: 18px;
  background: var(--surface-2);
  border-radius: 8px;
  line-height: 1.85;
  font-size: 17px;
  white-space: pre-wrap;
}

.question-list {
  display: grid;
  gap: 16px;
}

.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.question-card h4 {
  margin: 0 0 12px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
}

.result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f7f1df;
  color: #513c16;
}

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

.mistake-list,
.stats-grid {
  display: grid;
  gap: 14px;
}

.coverage-strip,
.catalog-grid {
  display: grid;
  gap: 14px;
}

.coverage-strip {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 18px;
}

.catalog-guide {
  padding: 16px 18px;
  margin-bottom: 18px;
}

.catalog-guide p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.catalog-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.catalog-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.catalog-card.imported {
  border-color: rgba(46, 125, 85, 0.45);
  background: #f1faf5;
}

.catalog-card h3 {
  margin: 0 0 8px;
}

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

.catalog-status {
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--warn);
}

.catalog-card.imported .catalog-status {
  background: var(--good);
}

.catalog-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.mistake-card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.mistake-card h3,
.stat-card h3 {
  margin: 0 0 10px;
}

.stat-value {
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 10px;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.word-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.word-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.word-card h3 {
  margin: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 3px 8px;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
}

.meaning-list {
  margin: 12px 0;
  display: grid;
  gap: 7px;
}

.meaning-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
}

.pos {
  color: var(--accent-2);
  font-weight: 800;
}

.word-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.word-actions button {
  padding: 7px 9px;
}

.review-card {
  max-width: 760px;
  min-height: 390px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  overflow: hidden;
  touch-action: pan-y;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.review-card.swipe-left {
  transform: translateX(-14px) rotate(-1deg);
}

.review-card.swipe-right {
  transform: translateX(14px) rotate(1deg);
}

.review-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.review-word {
  font-size: clamp(36px, 7vw, 64px);
  margin: 28px 0 8px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.review-meaning {
  margin-top: 24px;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-2);
}

.review-hint {
  display: grid;
  place-items: center;
  min-height: 120px;
  margin-top: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.review-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.source-note {
  margin: 0;
  padding: 18px 18px 0;
  color: var(--muted);
}

.source-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.source-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.source-item a {
  color: var(--accent);
  font-weight: 800;
}

.popover {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  width: min(420px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 32px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  padding: 16px;
}

.hidden {
  display: none;
}

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

.icon-button {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.definition-box {
  margin: 14px 0;
  display: grid;
  gap: 8px;
}

.definition-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

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

  .sidebar {
    min-height: auto;
  }

  .daily-card {
    margin-top: 0;
  }

  .toolbar,
  .paper-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .review-actions {
    grid-template-columns: 1fr 1fr;
  }
}
