@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600&family=Noto+Sans+TC:wght@400;500;700&family=Noto+Serif+TC:wght@600;700&display=swap");

:root {
  --bg: #f2f5f1;
  --paper: #ffffff;
  --text: #263238;
  --muted: #748078;
  --line: #e0e5df;
  --accent: #dd6548;
  --accent-dark: #bc4f36;
  --accent-soft: #f9e8e3;
  --green: #5c8b76;
  --green-soft: #e6f0ea;
  --blue: #547a9d;
  --blue-soft: #e8eff5;
  --yellow: #c9943a;
  --yellow-soft: #f8efd9;
  --danger: #b64a42;
  --danger-soft: #f8e8e6;
  --nav-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  min-height: 100%;
  background: var(--bg);
  overscroll-behavior-y: contain;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  color: #fff;
  background: #202c32;
  transform: translateZ(0);
  will-change: transform;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 21px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

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

.brand small {
  margin-top: 2px;
  color: #9eada7;
  font-size: 10px;
}

.sync-badge {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(92, 139, 118, 0.2);
  color: #b9decd;
  font-size: 10px;
  white-space: nowrap;
}

.sync-badge.error {
  background: rgba(182, 74, 66, 0.22);
  color: #ffc4bf;
}

main {
  width: min(100%, 860px);
  min-height: calc(100vh - 66px - var(--nav-h) - var(--safe-bottom));
  margin: 0 auto;
  padding: 18px 14px calc(var(--nav-h) + var(--safe-bottom) + 24px);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 6px 5px var(--safe-bottom);
  border-top: 1px solid rgba(224, 229, 223, 0.9);
  background: #ffffff;
  transform: translateZ(0);
  will-change: transform;
}

.nav-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.nav-item span {
  font-size: 20px;
  line-height: 1;
}

.nav-item small {
  font-size: 8.5px;
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.loading-card,
.card,
.hero-card,
.study-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 8px 30px rgba(35, 49, 43, 0.035);
}

.loading-card {
  margin-top: 18vh;
  padding: 34px 24px;
  text-align: center;
}

.loading-card h2 {
  margin: 16px 0 6px;
  font-size: 20px;
}

.loading-card p,
.muted {
  color: var(--muted);
}

.loader {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 3px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 2px 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.hero-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: var(--accent);
  content: "";
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.hero-card h2 {
  margin: 8px 0 6px;
  font-size: 21px;
  line-height: 1.35;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.ring {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--ratio, 0%), #edf0ec 0);
}

.ring-inner {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  text-align: center;
}

.ring-inner strong {
  display: block;
  font-size: 22px;
}

.ring-inner small {
  color: var(--muted);
  font-size: 9px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.btn {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--bg);
  font-weight: 700;
  cursor: pointer;
}

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

.btn.green {
  background: var(--green-soft);
  color: var(--green);
}

.btn.line {
  border-color: var(--line);
  background: #fff;
}

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.small {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 11px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.stat {
  padding: 12px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.stat b {
  display: block;
  margin-bottom: 3px;
  font-size: 18px;
}

.stat small {
  color: var(--muted);
  font-size: 9px;
}

.section {
  margin-top: 14px;
  padding: 16px;
}

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

.section-title h3 {
  margin: 0;
  font-size: 14px;
}

.section-title small {
  color: var(--muted);
  font-size: 9px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.lesson-chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
}

.lesson-chip.selected {
  border-color: #f0d0c7;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.study-wrap {
  min-height: calc(100vh - 130px);
}

.study-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
}

.study-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.favorite-toggle {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--yellow-soft);
  color: var(--yellow);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.favorite-toggle.active {
  border-color: #ead39e;
  background: #fff6df;
  color: #a97619;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  margin-bottom: 16px;
  border-radius: 999px;
  background: var(--line);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.study-card {
  padding: 22px 18px 18px;
  text-align: center;
}

.study-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

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

.listen-zone {
  padding: 36px 8px 20px;
}

.listen-icon {
  display: grid;
  width: 82px;
  height: 82px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 34px;
}

.listen-zone h2 {
  margin: 0;
  font-size: 22px;
}

.listen-zone p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.kana-input {
  width: 100%;
  min-height: 52px;
  margin-top: 18px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #fff;
  color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 20px;
  text-align: center;
}

.kana-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

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

.study-actions .btn {
  flex: 1;
}

.feedback {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  text-align: left;
}

.feedback.show {
  display: block;
}

.feedback.good {
  background: var(--green-soft);
}

.feedback.bad {
  background: var(--danger-soft);
}

.feedback strong {
  display: block;
  margin-bottom: 7px;
  font-size: 17px;
}

.feedback .answer-word {
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 22px;
  font-weight: 700;
}

.feedback p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.field,
.select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: #fff;
}

.select-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 12px;
}

.word-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr) minmax(0, 1.2fr);
  gap: 7px;
  margin-bottom: 12px;
}

.word-filter-row .select {
  min-width: 0;
  padding-right: 7px;
  padding-left: 7px;
  font-size: 10px;
}

.word-list {
  display: grid;
  gap: 8px;
}

.word-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.play-dot {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 14px;
}

.word-main strong {
  display: block;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 17px;
}

.word-main span,
.word-main small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.word-status {
  color: var(--blue);
  font-size: 9px;
  white-space: nowrap;
}

.word-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.word-fav {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--yellow-soft);
  color: var(--yellow);
  font-size: 16px;
}

.word-fav.active {
  border-color: #ead39e;
  background: #fff6df;
  color: #a97619;
}

.tabs-inline {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-inline::-webkit-scrollbar {
  display: none;
}

.tab-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
}

.tab-chip.active {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.reading-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.reading-toolbar .btn {
  min-height: 38px;
  padding: 8px 11px;
  font-size: 10px;
}

.reading-card {
  padding: 16px;
}

.reading-title {
  margin: 0 0 4px;
  font-size: 18px;
}

.reading-sub {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 10px;
}

.sentence {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 7px;
  align-items: start;
  margin-bottom: 7px;
  padding: 9px 8px;
  border-radius: 11px;
  transition: background 0.15s ease;
}

.sentence.current {
  background: var(--green-soft);
}

.sentence-play {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--green);
  box-shadow: 0 1px 5px rgba(35, 49, 43, 0.08);
}

.jp {
  padding-top: 4px;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 16px;
  line-height: 2.05;
  word-break: normal;
  overflow-wrap: anywhere;
}

ruby {
  ruby-position: over;
  ruby-align: center;
}

rt {
  color: var(--muted);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 0.48em;
  font-weight: 400;
}

details {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

summary {
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.note-block {
  padding: 10px 0 2px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.75;
  white-space: pre-line;
}

.grammar-card {
  margin-bottom: 10px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  contain: layout paint;
}

.conj-table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  margin: 4px -4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.conj-table {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
  font-size: 10px;
  line-height: 1.45;
}

.conj-table th {
  padding: 9px 7px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.conj-table td {
  padding: 8px 7px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.conj-table tbody tr:nth-child(even) {
  background: #f8faf7;
}

.conj-table td.form-name {
  color: var(--accent-dark);
  font-weight: 700;
  white-space: nowrap;
}

.conj-note {
  margin: 7px 0;
  padding: 10px 11px;
  border-radius: 10px;
  background: var(--bg);
}

.conj-note strong,
.conj-note span {
  display: block;
}

.conj-note strong {
  margin-bottom: 4px;
  color: var(--green);
  font-size: 11px;
}

.conj-note span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.exercise-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}

.exercise-score {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.exercise-card {
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}

.exercise-card.good {
  border-color: #cfe2d7;
  background: #f7fbf8;
}

.exercise-card.bad {
  border-color: #efd0cc;
  background: #fffafa;
}

.exercise-card.revealed {
  border-color: #cfdce7;
  background: #f9fbfd;
}

.q-number {
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 700;
}

.q-prompt {
  margin: 7px 0 10px;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-line;
}

.choice-options {
  display: grid;
  gap: 6px;
}

.choice {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 11px;
}

.choice input {
  flex: 0 0 auto;
}

.exercise-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 16px;
}

.exercise-feedback {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border-radius: 9px;
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-line;
}

.exercise-feedback.show {
  display: block;
}

.exercise-feedback.good {
  background: var(--green-soft);
  color: var(--green);
}

.exercise-feedback.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.exercise-feedback.info {
  background: var(--blue-soft);
  color: var(--blue);
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.grammar-num {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.grammar-card h3 {
  margin: 6px 0 7px;
  color: var(--accent-dark);
  font-size: 15px;
}

.grammar-card .explain {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.example {
  margin-top: 8px;
  padding: 10px;
  border-radius: 11px;
  background: var(--bg);
}

.example .zh {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.tip {
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 10px;
  line-height: 1.65;
}

.week-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  align-items: end;
  height: 150px;
  padding-top: 16px;
}

.day-bar {
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
}

.day-bar i {
  display: block;
  width: min(30px, 70%);
  min-height: 3px;
  border-radius: 8px 8px 3px 3px;
  background: #a9c2b5;
}

.day-bar.today i {
  background: var(--accent);
}

.day-bar small {
  color: var(--muted);
  font-size: 8px;
}

.lesson-progress {
  display: grid;
  gap: 7px;
}

.lesson-progress-row {
  display: grid;
  grid-template-columns: 50px 1fr 42px;
  gap: 8px;
  align-items: center;
  font-size: 10px;
}

.mini-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.mini-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row label {
  font-size: 12px;
  font-weight: 700;
}

.setting-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.setting-row input[type="number"],
.setting-row select {
  width: 92px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.switch {
  position: relative;
  width: 46px;
  height: 27px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #ccd4ce;
  transition: background 0.2s ease;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(19px);
}

.empty {
  padding: 36px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: 18px;
  z-index: 50;
  max-width: 620px;
  margin: auto;
  padding: 11px 15px;
  border-radius: 12px;
  background: rgba(32, 44, 50, 0.94);
  color: #fff;
  font-size: 11px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.result-card {
  padding: 30px 20px;
  text-align: center;
}

.result-check {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 15px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 32px;
  font-weight: 700;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 22px 0;
}

.result-stats strong {
  display: block;
  font-size: 24px;
}

.result-stats small {
  color: var(--muted);
  font-size: 9px;
}

@media (min-width: 620px) {
  main {
    padding-right: 22px;
    padding-left: 22px;
  }
  .hero-grid {
    grid-template-columns: 1fr auto;
  }
  .stats-grid {
    gap: 12px;
  }
  .stat {
    padding: 15px;
  }
}

@media (max-width: 380px) {
  .brand small {
    display: none;
  }
  .ring {
    width: 82px;
    height: 82px;
  }
  .ring-inner {
    width: 64px;
    height: 64px;
  }
  .lesson-grid {
    gap: 5px;
  }
  .nav-item small {
    font-size: 8px;
  }
}

/* Warm paper, muted ink and editorial cards inspired by Japanese study journals. */
:root {
  --bg: #d8d4ca;
  --paper: #fcfbf8;
  --text: #403e38;
  --muted: #8d887c;
  --line: #d4cec2;
  --accent: #8f7e6c;
  --accent-dark: #6f6154;
  --accent-soft: #ece6dd;
  --green: #6f7f6b;
  --green-soft: #e8ede6;
  --blue: #687f92;
  --blue-soft: #e7edf1;
  --yellow: #a27c43;
  --yellow-soft: #f3ead9;
  --danger: #9e5f54;
  --danger-soft: #f3e6e2;
  --nav-h: 64px;
}

html {
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 255, 255, 0.5), transparent 26rem),
    linear-gradient(145deg, #d5d1c8 0%, #e5e1d8 52%, #d9d5cc 100%);
}

body {
  background:
    linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16)),
    repeating-linear-gradient(90deg, rgba(92, 82, 67, 0.015) 0 1px, transparent 1px 5px);
  color: var(--text);
  font-family: "Noto Sans TC", "M PLUS 1", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-weight: 400;
  letter-spacing: 0.015em;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 88% 18%, rgba(143, 126, 108, 0.11), transparent 17rem),
    radial-gradient(circle at 10% 76%, rgba(139, 111, 71, 0.08), transparent 19rem);
  content: "";
  pointer-events: none;
}

.topbar {
  min-height: 72px;
  padding: max(12px, env(safe-area-inset-top)) 18px 11px;
  border-bottom: 1px solid rgba(180, 171, 157, 0.62);
  background: rgba(252, 251, 248, 0.9);
  color: var(--text);
  box-shadow: 0 2px 18px rgba(70, 63, 53, 0.05);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  gap: 11px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid #b9ad9d;
  border-radius: 50%;
  background: #f3efe7;
  color: var(--accent-dark);
  font-family: "Noto Serif TC", "Yu Mincho", serif;
  font-size: 20px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.45);
}

.brand strong {
  color: #393730;
  font-family: "Noto Serif TC", "Yu Mincho", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.brand small {
  margin-top: 1px;
  color: #918a7d;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.sync-badge {
  border: 1px solid rgba(143, 126, 108, 0.22);
  background: #ece6dd;
  color: #746657;
  font-weight: 500;
}

.sync-badge.error {
  border-color: rgba(158, 95, 84, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}

main {
  width: min(100%, 940px);
  padding: 20px 14px calc(var(--nav-h) + var(--safe-bottom) + 30px);
}

.loading-card,
.card,
.hero-card,
.study-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 2px 10px rgba(68, 61, 50, 0.035);
}

.page-head {
  align-items: center;
  margin: 6px 2px 18px;
  padding: 0 2px;
}

.page-head h1 {
  font-family: "Noto Serif TC", "Yu Mincho", serif;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.page-head p {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.035em;
}

.hero-card {
  min-height: 176px;
  padding: 25px 22px;
  background:
    radial-gradient(circle at 90% 14%, rgba(143, 126, 108, 0.17), transparent 8rem),
    linear-gradient(135deg, #fcfbf8 0%, #f2eee6 100%);
}

.hero-card::before {
  top: 22px;
  left: 0;
  width: 3px;
  height: calc(100% - 44px);
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.hero-card::after {
  position: absolute;
  right: 22px;
  bottom: 7px;
  color: rgba(111, 97, 84, 0.07);
  font-family: "Noto Serif TC", serif;
  font-size: 62px;
  font-weight: 700;
  letter-spacing: 0.08em;
  content: "言葉";
  pointer-events: none;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.hero-card h2 {
  margin: 9px 0 7px;
  font-family: "Noto Serif TC", "Yu Mincho", serif;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.hero-card p {
  color: var(--muted);
  letter-spacing: 0.03em;
}

.ring {
  position: relative;
  z-index: 1;
  background: conic-gradient(var(--accent) var(--ratio, 0%), #e5e1d9 0);
}

.ring-inner {
  background: var(--paper);
}

.ring-inner strong {
  font-family: "Cormorant Garamond", serif;
  font-size: 25px;
}

.actions {
  position: relative;
  z-index: 1;
}

.btn {
  min-height: 42px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(111, 97, 84, 0.16);
}

.btn.green {
  border: 1px solid rgba(111, 127, 107, 0.2);
  background: var(--green-soft);
  color: #586856;
}

.btn.line {
  border-color: #d4cec2;
  background: var(--paper);
  color: #6d655a;
}

.stats-grid {
  gap: 10px;
  margin: 13px 0;
}

.stat {
  padding: 14px 10px 13px;
  border-color: #d5cfc4;
  border-radius: 12px;
  background: rgba(252, 251, 248, 0.93);
  text-align: center;
}

.stat b {
  color: #514b42;
  font-family: "Cormorant Garamond", "Noto Serif TC", serif;
  font-size: 22px;
  font-weight: 600;
}

.stat small {
  color: #8d887c;
  letter-spacing: 0.08em;
}

.section {
  margin-top: 14px;
  padding: 18px;
}

.section-title {
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid #e2ddd4;
}

.section-title h3,
.section h2 {
  font-family: "Noto Serif TC", "Yu Mincho", serif;
  letter-spacing: 0.055em;
}

.section-title small {
  color: #918b7f;
}

.lesson-grid {
  gap: 8px;
}

.lesson-chip {
  min-height: 40px;
  border-color: #d4cec2;
  border-radius: 8px;
  background: #f7f4ee;
  color: #8b8478;
  font-family: "Cormorant Garamond", serif;
  font-size: 14px;
  font-weight: 600;
}

.lesson-chip.selected {
  border-color: #a99a89;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.study-card {
  padding: 28px 20px 22px;
}

.study-meta {
  color: #928b80;
}

.pill {
  border: 1px solid #d8d1c6;
  background: #f5f1eb;
  color: var(--accent-dark);
}

.listen-icon {
  border: 1px solid #d9d1c5;
  background: #f4f0e8;
  color: var(--accent);
}

.kana-input,
.field,
.select,
.setting-row input,
.setting-row select {
  border-color: #d6d0c4;
  border-radius: 10px;
  background: #fbfaf6;
  color: var(--text);
}

.kana-input:focus,
.field:focus,
.select:focus,
.setting-row input:focus,
.setting-row select:focus {
  border-color: #9e8d7b;
  box-shadow: 0 0 0 3px rgba(143, 126, 108, 0.1);
}

.word-row,
.grammar-card,
.exercise-card,
.conj-note,
.note-block {
  border-color: #ddd7cc;
  background: #fcfbf8;
}

.word-row {
  border-radius: 10px;
}

.grammar-card,
.exercise-card {
  border-radius: 12px;
}

.tabs-inline,
.word-filter-row {
  gap: 7px;
}

.tab-chip {
  border-color: #d6d0c4;
  border-radius: 999px;
  background: rgba(252, 251, 248, 0.7);
  color: #7d776d;
}

.tab-chip.active {
  border-color: #aa9b89;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.bottom-nav {
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 6px 8px var(--safe-bottom);
  border-top: 1px solid rgba(169, 160, 146, 0.62);
  background: rgba(252, 251, 248, 0.9);
  box-shadow: 0 -5px 22px rgba(65, 59, 49, 0.07);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-item {
  border-radius: 9px;
  color: #8a8478;
}

.nav-item span {
  font-family: "Noto Serif TC", serif;
  font-size: 18px;
}

.nav-item small {
  letter-spacing: 0.06em;
}

.nav-item.active {
  background: #ebe5dc;
  color: #6f6154;
}

.toast {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(64, 62, 56, 0.95);
  letter-spacing: 0.04em;
}

@media (min-width: 760px) {
  main {
    padding-right: 28px;
    padding-left: 28px;
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .lesson-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 520px) {
  .hero-card {
    padding: 22px 18px;
  }
  .hero-card h2 {
    font-size: 20px;
  }
  .hero-card::after {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar {
    padding-right: 14px;
    padding-left: 14px;
  }
}
