:root {
  color-scheme: light;
  --bg: #f3f4f2;
  --paper: #ffffff;
  --paper-muted: #f8f9f7;
  --ink: #26302b;
  --muted: #6f7973;
  --faint: #9ba49e;
  --line: #dfe4df;
  --line-strong: #cbd4cc;
  --green: #3f6654;
  --green-dark: #2e4e40;
  --green-soft: #e8f0eb;
  --red: #b85f4b;
  --red-soft: #f8ece8;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(63, 102, 84, 0.45);
  outline-offset: 2px;
}

.app-shell {
  width: min(1080px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar,
.brand,
.topbar-actions,
.save-status,
.view-nav,
.view-nav-button,
.page-intro,
.streak-card,
.card-heading,
.side-card-heading,
.practice-footer,
.view-heading,
.map-caption,
.site-footer,
.stroke-toolbar,
.stroke-filters,
.stroke-answer label {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 36px;
}

.brand {
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--green-dark);
  background: var(--paper);
  font-family: Georgia, serif;
  font-weight: 700;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  font-size: 14px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.topbar-actions {
  gap: 10px;
}

.save-status {
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6e9a79;
}

.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--paper);
  font-size: 17px;
}

.sync-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--green-dark);
  background: var(--paper);
  font-size: 11px;
  font-weight: 800;
}

.sync-button:hover,
.primary-sync-button:hover,
.secondary-sync-button:hover {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.page-intro {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.eyebrow,
.section-kicker,
.detail-kicker {
  margin: 0;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin: 7px 0 8px;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.intro-copy {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.streak-card {
  flex: 0 0 auto;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.streak-icon {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 13px;
}

.streak-card strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.view-nav {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 3px;
  width: fit-content;
  padding: 3px;
  margin-bottom: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.view-nav-button {
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
}

.view-nav-button.is-active {
  color: var(--green-dark);
  background: var(--green-soft);
}

.nav-icon {
  color: var(--green);
  font-size: 15px;
  line-height: 1;
}

.nav-count {
  display: inline-grid;
  min-width: 16px;
  height: 16px;
  place-items: center;
  padding: 0 4px;
  border-radius: 8px;
  color: var(--green-dark);
  background: #dce9df;
  font-size: 10px;
}

.view-panel[hidden] {
  display: none;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-bottom: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.stat-item {
  padding: 13px 16px;
  background: var(--paper);
}

.stat-item strong {
  display: block;
  margin-top: 7px;
  color: var(--green-dark);
  font-size: 20px;
  line-height: 1;
}

.stat-item small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.practice-layout,
.stroke-layout,
.key-learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(250px, 0.72fr);
  gap: 13px;
  align-items: start;
}

.practice-card,
.side-card,
.key-map-card,
.key-detail-card,
.stroke-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.practice-card,
.stroke-card,
.key-map-card {
  padding: 22px;
}

.card-heading,
.side-card-heading,
.view-heading {
  justify-content: space-between;
  gap: 15px;
}

.card-heading {
  margin-bottom: 18px;
}

.card-heading h2,
.side-card-heading h3,
.view-heading h2,
.key-detail-card h3 {
  margin-bottom: 0;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.card-heading h2 {
  margin-top: 6px;
  font-size: 20px;
}

.question-count {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--paper-muted);
  font-size: 10px;
  font-weight: 750;
}

.character-stage {
  display: grid;
  min-height: 205px;
  place-items: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-muted);
  text-align: center;
}

.prompt-label {
  color: var(--muted);
  font-size: 11px;
}

.character {
  margin: 9px 0 7px;
  color: var(--green-dark);
  font-family: "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
  font-size: clamp(82px, 13vw, 120px);
  line-height: 0.9;
}

.character-meta {
  color: var(--muted);
  font-size: 12px;
}

.answer-box,
.stroke-answer {
  margin-top: 16px;
}

.answer-box label,
.stroke-answer label {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.answer-box label span,
.stroke-answer label span {
  color: var(--faint);
  font-weight: 600;
}

.answer-row {
  display: flex;
  gap: 8px;
}

.answer-row input {
  min-width: 0;
  flex: 1;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
  color: var(--green-dark);
  background: var(--paper);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: lowercase;
}

.answer-row input::placeholder {
  color: #b5bdb7;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.answer-row input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(63, 102, 84, 0.11);
}

.submit-button,
.next-button {
  min-width: 76px;
  padding: 0 13px;
  border-radius: 7px;
  color: #fff;
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.submit-button:disabled,
.next-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.feedback {
  min-height: 21px;
  padding-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.feedback.is-correct {
  color: var(--green);
}

.feedback.is-wrong {
  color: var(--red);
}

.keyboard-wrap {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.keyboard-row-offset {
  padding: 0 4%;
}

.keyboard-row-offset-wide {
  padding: 0 8%;
}

.key-button {
  display: grid;
  min-width: 0;
  flex: 1;
  height: 37px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--paper-muted);
  font-size: 11px;
  font-weight: 800;
}

.key-button:active,
.key-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--green-soft);
}

.key-button-wide {
  flex: 1.4;
  color: var(--red);
}

.practice-footer {
  justify-content: space-between;
  gap: 12px;
  margin-top: 17px;
}

.text-button {
  padding: 6px 0;
  color: var(--green);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.next-button {
  min-height: 36px;
}

.practice-sidebar,
.stroke-summary {
  display: grid;
  gap: 13px;
}

.side-card {
  padding: 18px;
}

.side-card-heading {
  align-items: flex-start;
  margin-bottom: 12px;
}

.side-card-heading h3 {
  margin-top: 6px;
  font-size: 16px;
}

.route-progress {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.route-list {
  display: grid;
  gap: 1px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.route-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 9px;
  align-items: center;
  min-height: 50px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.route-item:last-child {
  border-bottom: 0;
}

.route-item.is-current .route-number {
  color: #fff;
  background: var(--green);
}

.route-number {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  color: var(--faint);
  background: var(--paper-muted);
  font-size: 9px;
  font-weight: 850;
}

.route-item strong,
.route-item small {
  display: block;
}

.route-item strong {
  font-size: 12px;
}

.route-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.tip-card {
  background: var(--paper-muted);
}

.tip-card::after,
.tip-mark {
  display: none;
}

.tip-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.tip-source {
  color: var(--faint);
  font-size: 10px;
}

.view-heading {
  align-items: flex-end;
  gap: 18px;
  margin: 7px 0 17px;
}

.view-heading h2 {
  margin: 7px 0 6px;
  font-size: clamp(24px, 4vw, 33px);
  line-height: 1.2;
}

.view-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.map-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--green);
  background: var(--paper);
  font-size: 10px;
  font-weight: 800;
}

.map-caption {
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--faint);
  font-size: 10px;
}

.map-caption-bottom {
  margin: 12px 0 0;
  color: var(--muted);
}

.full-key-map {
  display: grid;
  grid-template-columns: repeat(10, minmax(34px, 1fr));
  gap: 5px;
}

.map-key {
  display: grid;
  min-height: 75px;
  align-content: space-between;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--paper-muted);
  text-align: left;
}

.map-key:hover,
.map-key.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
}

.map-key strong {
  color: var(--green-dark);
  font-size: 16px;
}

.map-key span {
  min-height: 27px;
  font-size: 9px;
  line-height: 1.45;
}

.key-detail-card {
  min-height: 235px;
  padding: 20px;
  color: var(--ink);
  background: var(--paper);
}

.key-detail-card .detail-kicker {
  color: var(--green);
}

.detail-key {
  margin: 10px 0 2px;
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 42px;
  line-height: 1;
}

.key-detail-card h3 {
  font-size: 17px;
}

.key-detail-card p {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.detail-example {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.detail-example strong {
  color: var(--green-dark);
  font-size: 11px;
}

.stroke-card {
  padding-bottom: 18px;
}

.stroke-toolbar {
  justify-content: space-between;
  gap: 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.stroke-filters {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.filter-button {
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--paper);
  font-size: 10px;
  font-weight: 750;
}

.filter-button.is-active {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--green-soft);
}

.stroke-prompt {
  display: grid;
  min-height: 200px;
  place-items: center;
  padding: 25px 15px 21px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-muted);
  text-align: center;
}

.stroke-symbol {
  margin: 12px 0 5px;
  color: var(--green-dark);
  font-family: "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
  font-size: 72px;
  line-height: 0.9;
}

.stroke-name {
  font-size: 15px;
}

.stroke-roots {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stroke-session-score {
  color: var(--muted);
  font-size: 11px;
}

.stroke-zone-list {
  display: grid;
  gap: 7px;
}

.stroke-zone-row {
  display: grid;
  grid-template-columns: 36px 42px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

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

.stroke-zone-symbol {
  display: grid;
  width: 32px;
  height: 28px;
  place-items: center;
  border-radius: 5px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-family: Georgia, serif;
  font-weight: 800;
}

.stroke-zone-name {
  color: var(--muted);
  font-size: 11px;
}

.stroke-zone-keys {
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.05em;
}

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

.mistake-item {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 11px;
  align-items: center;
  min-height: 73px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.mistake-character {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 7px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-family: "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
  font-size: 27px;
}

.mistake-info strong,
.mistake-info span {
  display: block;
}

.mistake-info strong {
  font-size: 13px;
}

.mistake-info span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.mistake-retry {
  min-height: 31px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--green);
  background: var(--paper);
  font-size: 10px;
  font-weight: 800;
}

.mistake-retry:hover {
  color: #fff;
  background: var(--green);
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 15px;
}

.empty-state span {
  font-size: 11px;
  line-height: 1.6;
}

.site-footer {
  justify-content: space-between;
  gap: 12px;
  padding: 22px 1px 0;
  color: var(--faint);
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  max-width: min(320px, calc(100% - 32px));
  padding: 10px 12px;
  border-radius: 7px;
  color: #fff;
  background: var(--green-dark);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sync-panel[hidden] {
  display: none;
}

.sync-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
}

.sync-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 48, 43, 0.24);
}

.sync-dialog {
  position: relative;
  width: min(430px, 100%);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 16px 42px rgba(38, 48, 43, 0.2);
}

.sync-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sync-dialog h2 {
  margin: 6px 0 0;
  font-size: 20px;
}

.sync-copy {
  margin: 14px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.sync-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-muted);
}

.sync-code-box span,
.sync-input-label {
  color: var(--muted);
  font-size: 11px;
}

.sync-code-box strong {
  color: var(--green-dark);
  font-size: 17px;
  letter-spacing: 0.12em;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 10px 0 16px;
}

.primary-sync-button,
.secondary-sync-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--green);
  border-radius: 7px;
  color: #fff;
  background: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.secondary-sync-button {
  border-color: var(--line);
  color: var(--muted);
  background: var(--paper);
}

.secondary-sync-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sync-input-label {
  display: block;
  margin-bottom: 7px;
}

.sync-input-row {
  display: flex;
  gap: 7px;
}

.sync-input-row input {
  min-width: 0;
  flex: 1;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
  color: var(--green-dark);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sync-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.sync-status.is-success {
  color: var(--green);
}

.sync-status.is-error {
  color: var(--red);
}

@media (max-width: 760px) {
  .practice-layout,
  .stroke-layout,
  .key-learning-layout {
    grid-template-columns: 1fr;
  }

  .practice-sidebar,
  .stroke-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 20px);
    padding-top: 13px;
  }

  .topbar {
    margin-bottom: 27px;
  }

  .save-status {
    display: none;
  }

  .sync-button {
    min-height: 29px;
    padding: 0 8px;
  }

  .page-intro {
    display: block;
    margin-bottom: 20px;
  }

  .streak-card {
    width: fit-content;
    margin-top: 14px;
  }

  .view-nav {
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .view-nav-button {
    gap: 2px;
    padding: 0 3px;
    font-size: 10px;
  }

  .nav-icon {
    display: none;
  }

  .stats-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-item {
    padding: 12px 8px;
  }

  .stat-item strong {
    font-size: 17px;
  }

  .stat-item small {
    display: block;
    margin-top: 4px;
    font-size: 9px;
  }

  .practice-card,
  .stroke-card,
  .key-map-card {
    padding: 15px;
  }

  .card-heading {
    align-items: flex-start;
    margin-bottom: 15px;
  }

  .card-heading h2 {
    font-size: 18px;
  }

  .character-stage,
  .stroke-prompt {
    min-height: 185px;
  }

  .character {
    font-size: 96px;
  }

  .keyboard-row {
    gap: 4px;
  }

  .keyboard-row-offset {
    padding: 0 3%;
  }

  .keyboard-row-offset-wide {
    padding: 0 6%;
  }

  .key-button {
    height: 36px;
  }

  .practice-sidebar,
  .stroke-summary {
    grid-template-columns: 1fr;
  }

  .view-heading {
    display: block;
    margin-top: 5px;
  }

  .view-heading h2 {
    font-size: 27px;
  }

  .map-badge {
    display: inline-block;
    margin-top: 12px;
  }

  .full-key-map {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .map-key {
    min-height: 68px;
  }

  .stroke-toolbar {
    display: block;
  }

  .stroke-filters {
    justify-content: flex-start;
    margin-top: 10px;
  }

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

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
