:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --text: #1e2428;
  --muted: #647072;
  --line: #ded9cc;
  --accent: #286f6c;
  --accent-dark: #1d5553;
  --accent-soft: #d9ebe7;
  --gold: #a76524;
  --danger: #b44848;
  --ok: #2f7d4f;
  --shadow: 0 18px 45px rgba(33, 38, 40, 0.08);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(100%, 460px);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-brand {
  margin-bottom: 20px;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #ebe7dc;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.stats-panel h3 {
  margin: 0;
}

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

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

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

.nav-button,
.bottom-button {
  min-height: 44px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
}

.nav-button {
  text-align: left;
  padding: 0 14px;
}

.nav-button:hover,
.bottom-button:hover,
.nav-button.is-active,
.bottom-button.is-active {
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0 auto 18px;
  max-width: 1280px;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.2;
}

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

.primary-button,
.ghost-button,
.choice-button,
.rating-button,
.small-button,
.danger-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.ghost-button,
.small-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: #f8dddd;
  color: var(--danger);
  border: 1px solid #e8baba;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

body.is-master .content-grid {
  grid-template-columns: minmax(0, 1fr);
}

body.is-master .stats-panel,
body.is-master .learner-only {
  display: none !important;
}

.workspace,
.stats-panel,
.study-card,
.panel,
.item-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workspace {
  min-height: calc(100vh - 118px);
  padding: 20px;
}

.stats-panel {
  padding: 18px;
  position: sticky;
  top: 24px;
}

.stats-panel h3 {
  font-size: 18px;
  margin-bottom: 14px;
}

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

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf8f2;
}

.stat-row span,
.mastery span,
.meta,
.muted {
  color: var(--muted);
}

.mastery {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.meter {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e2ded3;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

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

.panel,
.item-card {
  padding: 16px;
}

.panel h3,
.item-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.panel strong {
  font-size: 32px;
}

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

.study-card {
  padding: 22px;
}

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

.word-title {
  margin: 0;
  font-size: 42px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.grammar-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pronunciation-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.phonetic {
  color: var(--muted);
  font-size: 18px;
}

.audio-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #bdd8d2;
  font-size: 15px;
  font-weight: 800;
}

.audio-button:hover {
  background: var(--accent);
  color: white;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 650;
}

.tag.gold {
  background: #f2e0c8;
  color: var(--gold);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.detail-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.detail-block h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.detail-block p,
.detail-block ul {
  margin: 0;
}

.detail-block ul {
  padding-left: 20px;
}

.example {
  font-size: 18px;
  line-height: 1.65;
}

.zh {
  color: var(--muted);
  margin-top: 6px;
}

.rating-row,
.choice-grid {
  display: grid;
  gap: 10px;
}

.rating-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.rating-button {
  color: var(--text);
  background: #f4f0e7;
  border: 1px solid var(--line);
}

.rating-button[data-rating="easy"] {
  background: #e0f0e6;
  color: var(--ok);
}

.rating-button[data-rating="forgot"] {
  background: #f7dede;
  color: var(--danger);
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.choice-button {
  text-align: left;
  background: #f8f6ef;
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 54px;
}

.choice-button.is-correct {
  border-color: var(--ok);
  background: #e4f1e8;
}

.choice-button.is-wrong {
  border-color: var(--danger);
  background: #f7e0e0;
}

.feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f4f0e7;
  border: 1px solid var(--line);
}

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

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

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

.item-title {
  margin: 0;
  font-size: 20px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  text-align: center;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.field {
  display: grid;
  gap: 6px;
}

.field input,
.field textarea,
.field select {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: white;
  color: var(--text);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

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

.level-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf8f2;
}

.level-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.bottom-nav {
  display: none;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 68px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 12px;
  }

  .topbar h2 {
    font-size: 24px;
  }

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

  .workspace,
  .stats-panel {
    padding: 14px;
    box-shadow: none;
  }

  .workspace {
    min-height: 0;
  }

  .content-grid,
  .dashboard-grid,
  .detail-grid,
  .choice-grid,
  .rating-row,
  .level-grid {
    grid-template-columns: 1fr;
  }

  .study-card {
    padding: 16px;
    box-shadow: none;
  }

  .study-head {
    display: grid;
  }

  .word-title {
    font-size: 34px;
  }

  .grammar-title {
    font-size: 23px;
  }

  .rating-row {
    position: sticky;
    bottom: 76px;
    background: var(--surface-strong);
    padding-top: 10px;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 4px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px;
    border-top: 1px solid var(--line);
    background: rgba(247, 245, 239, 0.96);
    backdrop-filter: blur(12px);
    z-index: 20;
  }

  .bottom-button {
    font-size: 13px;
    padding: 0 4px;
  }
}
