:root {
  --bg: #f7f5ee;
  --ink: #20252b;
  --muted: #69717a;
  --line: #dad6ca;
  --panel: #ffffff;
  --accent: #1d6f64;
  --accent-strong: #124f49;
  --danger: #b84848;
  --warn: #b27523;
  --success: #23734f;
  --focus: #c13f32;
  --focus-bg: #fff0ec;
  --shadow: 0 18px 60px rgba(32, 37, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(29, 111, 100, 0.08), transparent 38%),
    linear-gradient(315deg, rgba(178, 117, 35, 0.08), transparent 42%),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", Arial, 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 {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(14px);
}

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

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

.brand h1,
.brand p,
.eyebrow,
.section-head h2,
.topbar h2 {
  margin: 0;
}

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

.brand p,
.eyebrow,
.hint {
  color: var(--muted);
}

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

.stat {
  display: grid;
  align-content: center;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  font-size: 22px;
}

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

.tab {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  padding: 0 14px;
}

.tab.is-active {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
  box-shadow: 0 8px 22px rgba(32, 37, 43, 0.07);
}

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

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 13px;
  letter-spacing: 0;
}

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

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

.icon-button,
.ghost-button,
.primary-button,
.danger-button,
.warn-button,
.success-button,
.sound-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.ghost-button {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.danger-button,
.warn-button,
.success-button {
  color: #fff;
  font-weight: 700;
}

.danger-button {
  background: var(--danger);
}

.warn-button {
  background: var(--warn);
}

.success-button {
  background: var(--success);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.study-layout {
  display: grid;
  gap: 18px;
  max-width: 760px;
}

.plan-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.plan-panel h3 {
  margin: 0;
  font-size: 22px;
}

.plan-panel p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.plan-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 190px;
}

.plan-chips span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

#focusChip,
.badge.is-focus {
  border-color: rgba(193, 63, 50, 0.35);
  color: var(--focus);
  background: var(--focus-bg);
}

.word-card {
  position: relative;
  min-height: 430px;
  padding: 26px;
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(29, 111, 100, 0.09), transparent 52%),
    var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.word-card.is-focus {
  outline: 2px solid rgba(193, 63, 50, 0.38);
  background:
    linear-gradient(160deg, rgba(193, 63, 50, 0.11), transparent 48%),
    var(--panel);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

.sound-button {
  position: absolute;
  top: 64px;
  right: 26px;
  width: 44px;
  padding: 0;
  color: #fff;
  background: var(--ink);
}

.word-main {
  display: grid;
  min-height: 180px;
  align-content: center;
  padding-right: 54px;
}

.word {
  margin: 0;
  font-size: clamp(44px, 8vw, 82px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.phonetic {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 20px;
}

.answer {
  min-height: 120px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
}

.answer.is-shown {
  opacity: 1;
  transform: translateY(0);
}

.detail-sections {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

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

.detail-section h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.detail-section p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.65;
}

.meaning {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 700;
}

.example {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.controls {
  display: grid;
  gap: 12px;
}

.controls > button {
  width: 100%;
}

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

.rating-row[hidden] {
  display: none;
}

.search {
  width: min(320px, 100%);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

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

.word-item {
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.word-item.needs-focus {
  border-color: rgba(193, 63, 50, 0.38);
  background: var(--focus-bg);
}

.word-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

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

.word-item p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

.word-item small {
  color: var(--accent-strong);
  font-weight: 700;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
}

.needs-focus .mini-button {
  border-color: rgba(193, 63, 50, 0.38);
  color: var(--focus);
}

.schedule-list {
  display: grid;
  gap: 12px;
  max-width: 780px;
}

.schedule-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.schedule-item h3,
.schedule-item p {
  margin: 0;
}

.schedule-item p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.schedule-item strong {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-strong);
}

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

.import-box {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

textarea {
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: #fff;
  line-height: 1.6;
}

.import-actions {
  display: grid;
  align-content: start;
  gap: 10px;
}

.hint {
  margin: 6px 0 0;
  line-height: 1.5;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .tab {
    text-align: center;
  }

  .content {
    padding: 22px;
  }

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

@media (max-width: 560px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-panel,
  .rating-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .plan-chips {
    justify-content: flex-start;
    min-width: 0;
  }

  .word-card {
    min-height: 390px;
    padding: 20px;
  }

  .sound-button {
    top: 58px;
    right: 20px;
  }
}

.meaning,
.detail-section p,
.phonetic {
  letter-spacing: 0;
  word-spacing: 0;
}
/* Answer reveal and readable examples */
.answer {
  visibility: hidden;
  pointer-events: none;
}

.answer.is-shown {
  visibility: visible;
  pointer-events: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.section-title button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.example-list,
.note-list {
  display: grid;
  gap: 12px;
}

.example-item,
.note-card {
  padding: 14px 16px;
  border: 1px solid rgba(31, 41, 55, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.example-item p,
.note-card p {
  margin: 0;
  line-height: 1.7;
}

.example-item p + p,
.note-card p + p {
  margin-top: 6px;
}

.example-item .english {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

.example-item .translation {
  color: var(--muted);
  font-size: 16px;
}

.example-item small {
  display: block;
  margin-top: 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

mark {
  color: #c13f32;
  background: transparent;
  font-weight: 900;
}

.note-card {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

@media (max-width: 560px) {
  .example-item .english {
    font-size: 16px;
  }

  .example-item .translation,
  .note-card {
    font-size: 15px;
  }
}
.undo-button {
  justify-self: start;
  min-width: 132px;
}

.undo-button:disabled {
  cursor: default;
  opacity: 0.46;
}
/* PWA mobile shell */
html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@media (max-width: 760px) {
  .app-shell {
    min-height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(247, 245, 238, 0.94);
  }

  .brand {
    display: none;
  }

  .stats-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .stat {
    min-height: 48px;
    padding: 8px;
  }

  .stat span {
    font-size: 11px;
  }

  .stat strong {
    font-size: 18px;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .tab {
    min-height: 38px;
    padding: 0 8px;
    text-align: center;
  }

  .content {
    padding: 14px 14px 108px;
  }

  .topbar {
    display: none;
  }

  .study-layout {
    max-width: none;
    gap: 12px;
  }

  .plan-panel {
    padding: 14px;
  }

  .plan-panel h3 {
    font-size: 18px;
  }

  .plan-panel p:last-child {
    font-size: 13px;
  }

  .word-card {
    min-height: calc(100dvh - 306px);
    padding: 18px;
  }

  .word-main {
    min-height: 150px;
  }

  .word {
    font-size: clamp(52px, 18vw, 78px);
  }

  .phonetic {
    font-size: 18px;
  }

  .sound-button {
    top: 54px;
    right: 18px;
    width: 42px;
    min-height: 42px;
  }

  .answer {
    padding: 16px;
  }

  .meaning {
    font-size: 20px;
    line-height: 1.45;
  }

  .controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(218, 214, 202, 0.9);
    background: rgba(247, 245, 238, 0.96);
    backdrop-filter: blur(12px);
  }

  .rating-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .rating-row button {
    min-height: 54px;
    padding: 0 8px;
    font-size: 17px;
  }

  .undo-button {
    width: 100%;
    min-height: 38px;
  }

  .section-head {
    gap: 10px;
  }

  .search {
    width: 100%;
  }

  .word-list {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    padding: 22px;
  }

  .content {
    padding: 24px;
  }

  .study-layout {
    max-width: 820px;
  }
}
