:root {
  color-scheme: light;
  --paper: #fbf9f4;
  --surface: #ffffff;
  --surface-soft: #f5f1e9;
  --ink: #26322f;
  --muted: #77827d;
  --line: #e9e4da;
  --accent: #e36f4d;
  --accent-dark: #be5537;
  --green: #426e5f;
  --shadow: 0 12px 28px rgba(48, 55, 49, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 110% -10%, rgba(249, 215, 189, 0.7), transparent 32%),
    var(--paper);
  font-family:
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  height: 76px;
  padding: 12px 20px;
}

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

.brand-mark,
.vocab-entry-icon,
.empty-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--green);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px 13px 13px 5px;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 700;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0.05em;
}

.brand-copy small,
.topic-copy small,
.subtopic-row small,
.subtopic-heading small,
.third-topic-row small,
.vocab-entry-copy small {
  color: var(--muted);
}

.brand-copy small {
  font-size: 10px;
  letter-spacing: 0.14em;
}

.app-main {
  padding: 9px 20px 100px;
}

.home-hero {
  padding: 25px 4px 24px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 11px;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.25;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  letter-spacing: -0.03em;
}

.hero-copy {
  max-width: 410px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.vocab-entry {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 84px;
  padding: 15px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(135deg, #477564, #315c50);
  box-shadow: 0 13px 28px rgba(58, 101, 87, 0.22);
}

.vocab-entry-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  color: var(--green);
  background: #f7e8c8;
  font-size: 20px;
  font-weight: 800;
}

.vocab-entry-copy {
  display: grid;
  flex: 1;
  gap: 5px;
}

.vocab-entry-copy strong {
  font-size: 17px;
}

.vocab-entry-copy small {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
}

.vocab-entry-count {
  min-width: 24px;
  color: #f8e4b9;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.arrow {
  font-family: Arial, sans-serif;
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
}

.topics-section {
  padding-top: 39px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 17px;
  padding: 0 3px;
}

.section-heading .eyebrow {
  margin-bottom: 6px;
}

.section-heading > span {
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.topic-block {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(48, 55, 49, 0.025);
}

.topic-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 85px;
  padding: 14px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.topic-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 47px;
  height: 47px;
  border-radius: 15px;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 800;
}

.topic-icon.peach {
  color: #c96140;
  background: #fce2d1;
}

.topic-icon.mint {
  color: #397060;
  background: #ddefe6;
}

.topic-icon.lilac {
  color: #775b8e;
  background: #eee3f4;
}

.topic-copy {
  display: grid;
  flex: 1;
  gap: 5px;
  min-width: 0;
  padding-left: 13px;
}

.topic-copy strong {
  font-size: 16px;
}

.topic-copy small,
.subtopic-heading small,
.third-topic-row small {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-count {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
}

.chevron {
  width: 9px;
  height: 9px;
  margin: 0 6px 5px 9px;
  border-right: 1.5px solid #9fa9a4;
  border-bottom: 1.5px solid #9fa9a4;
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.topic-block.is-open .chevron {
  margin-bottom: -1px;
  transform: rotate(225deg);
}

.subtopic-list {
  display: none;
  padding: 2px 14px 10px 74px;
}

.topic-block.is-open .subtopic-list {
  display: block;
}

.subtopic-row,
.subtopic-group {
  border-top: 1px solid var(--line);
}

.subtopic-row,
.subtopic-heading,
.third-topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
}

.subtopic-heading {
  width: 100%;
  padding: 9px 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.third-topic-list {
  display: none;
  padding-left: 13px;
}

.subtopic-group.is-open .third-topic-list {
  display: block;
}

.third-topic-row {
  border-top: 1px solid var(--line);
}

.subtopic-row > span:first-child,
.subtopic-heading > span:first-child,
.third-topic-row > span:first-child {
  display: grid;
  flex: 1;
  gap: 5px;
  min-width: 0;
}

.subtopic-row strong,
.subtopic-heading strong {
  font-size: 14px;
}

.subtopic-row small,
.subtopic-heading small {
  color: var(--muted);
}

.third-topic-row strong {
  font-size: 13px;
}

.third-topic-row small {
  color: var(--muted);
}

.subtopic-meta {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.subtopic-row .arrow,
.third-topic-row .arrow {
  color: #afb6b1;
  font-size: 22px;
}

.group-chevron {
  width: 8px;
  height: 8px;
  margin: 0 6px 4px 1px;
  border-right: 1.5px solid #9fa9a4;
  border-bottom: 1.5px solid #9fa9a4;
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.subtopic-group.is-open .group-chevron {
  margin-bottom: -2px;
  transform: rotate(225deg);
}

.page-heading {
  display: flex;
  gap: 13px;
  padding: 26px 0 21px;
}

.back-link {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green);
  background: rgba(255, 255, 255, 0.72);
  font-family: Arial, sans-serif;
  font-size: 29px;
  line-height: 1;
}

.page-heading h1 {
  margin-bottom: 7px;
  font-size: clamp(27px, 7vw, 34px);
}

.page-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.study-list {
  display: grid;
  gap: 13px;
}

.study-card {
  position: relative;
  padding: 18px 16px 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(48, 55, 49, 0.025);
}

.zh-row {
  margin-bottom: 9px;
  padding-right: 54px;
}

.study-card.mode-en .zh-row {
  display: none;
}

.study-card.mode-en .en-text {
  padding-right: 54px;
}

.zh-text {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
}

.vocab-button {
  position: absolute;
  top: 18px;
  right: 16px;
  min-width: 43px;
  padding: 5px 7px;
  border: 1px solid #f0c8b8;
  border-radius: 9px;
  color: var(--accent-dark);
  background: #fff5ef;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.vocab-button.is-saved,
.vocab-button:disabled {
  border-color: #e1e4df;
  color: #a4aca7;
  background: #f5f6f3;
  cursor: default;
}

.en-text {
  margin-bottom: 0;
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.32;
}

.example-text {
  margin: 11px 0 0;
  padding-top: 11px;
  border-top: 1px dashed #e6e2d9;
  color: #68746f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.55;
}

.example-text span {
  margin-right: 6px;
  color: var(--accent);
  font-family:
    "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 11px;
  font-weight: 800;
}

.source-label {
  display: inline-flex;
  margin-top: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
}

.is-hidden {
  display: none;
}

.filter-control {
  position: fixed;
  right: max(20px, calc((100vw - 680px) / 2));
  bottom: 25px;
  z-index: 5;
  display: flex;
  align-items: center;
}

.filter-options {
  position: absolute;
  right: 63px;
  bottom: 5px;
  display: flex;
  flex-direction: row-reverse;
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.filter-control.is-open .filter-options {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.filter-trigger,
.filter-option {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.filter-trigger {
  width: 55px;
  height: 55px;
  border: 0;
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 20px rgba(55, 98, 84, 0.3);
}

.filter-option {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  color: var(--green);
  background: #fff;
  box-shadow: var(--shadow);
}

.filter-option.is-active {
  border-color: #d6e9df;
  background: #e7f2ed;
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 62px 25px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.8);
  text-align: center;
}

.empty-icon {
  width: 62px;
  height: 62px;
  margin-bottom: 18px;
  border-radius: 20px;
  color: var(--green);
  background: #edf4f0;
  font-size: 24px;
  font-weight: 800;
}

.empty-state h2 {
  margin-bottom: 10px;
}

.empty-state p {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.primary-link {
  padding: 11px 17px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 97px;
  left: 50%;
  z-index: 10;
  padding: 10px 15px;
  border-radius: 999px;
  color: #fff;
  background: rgba(35, 47, 43, 0.9);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.floating-back,
.back-to-top {
  position: fixed;
  right: max(20px, calc((100vw - 680px) / 2));
  z-index: 5;
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  border: 1px solid #d6e9df;
  border-radius: 50%;
  color: var(--green);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  font-size: 23px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.floating-back {
  bottom: 92px;
  font-size: 22px;
}

.back-to-top {
  bottom: 159px;
  font-size: 23px;
}

.floating-back.is-visible,
.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (min-width: 720px) {
  .app-main,
  .app-header {
    padding-right: 28px;
    padding-left: 28px;
  }
}
