:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #eeeeea;
  --text: #171a18;
  --muted: #626964;
  --border: #d7dbd8;
  --primary: #245f52;
  --primary-hover: #19483e;
  --primary-soft: #e4eeeb;
  --danger: #b63832;
  --new: #bd4a42;
  --learning: #966d16;
  --review: #286a59;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a18;
  --surface: #222624;
  --surface-2: #2c312e;
  --text: #f2f3f1;
  --muted: #a9b0ab;
  --border: #3c423e;
  --primary: #77b7a5;
  --primary-hover: #92c9ba;
  --primary-soft: #2b403a;
  --danger: #ef7770;
  --new: #ef8179;
  --learning: #d8b35d;
  --review: #77b7a5;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
}

svg.icon {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.boot-screen {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  justify-items: center;
}

.boot-screen p {
  margin: 12px 0 0;
  font-size: 18px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-zh);
  font-size: 23px;
}

.app-layout {
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 19px;
}

.desktop-nav {
  display: grid;
  gap: 4px;
  margin-top: 42px;
}

.nav-item {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.main-content {
  width: calc(100% - 220px);
  min-height: 100dvh;
  margin-left: 220px;
  padding: 42px clamp(28px, 5vw, 72px) 72px;
}

.main-content > * {
  width: min(100%, 900px);
  margin-right: auto;
  margin-left: auto;
}

.page-header {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.03em;
}

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

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 650;
}

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

:root[data-theme="dark"] .button-primary {
  color: #14201c;
}

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

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover,
.button-quiet:hover {
  background: var(--surface-2);
}

.button-quiet {
  background: transparent;
  color: var(--primary);
}

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

.button-block {
  width: 100%;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.review-summary,
.panel,
.deck-list,
.vocab-list,
.settings-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.review-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 32px;
}

.review-total {
  display: grid;
  min-width: 140px;
}

.review-total strong {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
}

.review-total span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 17px;
}

.due-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}

.due-breakdown span {
  color: var(--muted);
  font-size: 15px;
}

.due-breakdown strong {
  color: var(--text);
  font-size: 18px;
}

.start-button {
  min-width: 130px;
}

.study-actions {
  display: grid;
  gap: 8px;
}

.today-count {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 15px;
}

.decks-section {
  margin-top: 38px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 23px;
}

.section-heading > span {
  color: var(--muted);
  font-size: 14px;
}

.deck-list {
  overflow: hidden;
}

.deck-row {
  display: grid;
  min-height: 76px;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 12px 14px 12px 20px;
}

.deck-row + .deck-row {
  border-top: 1px solid var(--border);
}

.deck-main {
  min-width: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.deck-copy,
.deck-copy strong,
.deck-copy span {
  display: block;
}

.deck-copy strong {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-copy span,
.deck-due {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.deck-study {
  min-width: 76px;
}

/* Card library */
.library-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 150px;
  gap: 10px;
  margin-bottom: 18px;
}

.search-field,
.select-field {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.search-field svg {
  color: var(--muted);
}

.search-field input,
.select-field select {
  width: 100%;
  height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}

.card-count {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.vocab-list {
  overflow: hidden;
}

.vocab-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.vocab-row + .vocab-row {
  border-top: 1px solid var(--border);
}

.vocab-row.is-suspended {
  opacity: 0.55;
}

.vocab-main {
  display: grid;
  min-width: 0;
  min-height: 86px;
  grid-template-columns: 100px minmax(150px, 1fr) minmax(120px, 0.7fr) 100px;
  align-items: center;
  gap: 18px;
  padding: 12px 14px 12px 20px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.vocab-main:hover {
  background: var(--surface-2);
}

.vocab-hanzi {
  overflow: hidden;
  font-family: var(--font-zh);
  font-size: 32px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vocab-reading,
.vocab-reading strong,
.vocab-reading small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vocab-reading strong {
  font-size: 16px;
}

.vocab-reading small,
.vocab-deck,
.vocab-due small {
  color: var(--muted);
  font-size: 14px;
}

.vocab-reading small,
.vocab-due small {
  display: block;
  margin-top: 3px;
}

.vocab-deck {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.deck-dot-coral { background: var(--new); }
.deck-dot-jade { background: var(--review); }
.deck-dot-gold { background: var(--learning); }
.deck-dot-blue { background: #47749b; }

.status-pill {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: capitalize;
}

.status-new { color: var(--new); }
.status-learning { color: var(--learning); }
.status-review { color: var(--review); }

.vocab-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 10px;
}

.vocab-actions .icon-button {
  border-color: transparent;
}

.empty-state {
  display: grid;
  min-height: 320px;
  place-content: center;
  justify-items: center;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: center;
}

.empty-character {
  margin-bottom: 10px;
  font-family: var(--font-zh);
  font-size: 54px;
}

.empty-state h1,
.empty-state h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.empty-state p {
  max-width: 420px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 16px;
}

/* Progress */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  display: grid;
  min-height: 120px;
  place-content: center;
  justify-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.metric-card strong {
  font-size: 34px;
}

.metric-card span {
  color: var(--muted);
  font-size: 15px;
}

.progress-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 0.7fr);
  gap: 20px;
}

.panel {
  padding: 22px;
}

.activity-chart {
  display: grid;
  height: 260px;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 12px;
  padding-top: 18px;
}

.chart-day {
  display: grid;
  height: 100%;
  grid-template-rows: 24px 1fr 28px;
  justify-items: center;
}

.chart-day > span,
.chart-day > b {
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  position: relative;
  width: min(34px, 70%);
  height: 100%;
  border-bottom: 1px solid var(--border);
}

.bar-track i {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}

.memory-panel h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.memory-panel h2:not(:first-child) {
  margin-top: 28px;
}

.memory-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.memory-row span {
  color: var(--muted);
}

/* Settings */
.settings-layout {
  display: grid;
  gap: 18px;
  max-width: 720px;
}

.settings-section {
  overflow: hidden;
  padding: 22px;
}

.settings-section h2 {
  margin-bottom: 8px;
  font-size: 21px;
}

.settings-explanation,
.help-text {
  color: var(--muted);
  font-size: 14px;
}

.settings-explanation {
  margin-bottom: 18px;
}

.help-text {
  display: block;
  margin-top: 2px;
}

.setting-row {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--border);
}

.setting-row strong {
  font-size: 15px;
}

.setting-row input[type="number"],
.setting-row input[type="time"] {
  width: 76px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  text-align: center;
}

.setting-row input[type="time"] {
  width: 112px;
  padding: 0 8px;
}

.switch {
  position: relative;
  width: 46px;
  height: 27px;
  flex: 0 0 auto;
  border-radius: 20px;
  background: var(--border);
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
}

.switch.is-on {
  background: var(--primary);
}

.switch.is-on span {
  transform: translateX(19px);
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.theme-choice {
  position: relative;
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 15px;
}

.theme-choice.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.theme-choice > svg:last-child {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 14px;
}

.install-setting-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.install-setting-card strong {
  font-size: 16px;
}

.action-list {
  margin: 0 -22px -22px;
  border-top: 1px solid var(--border);
}

.action-list button {
  display: grid;
  width: 100%;
  min-height: 68px;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.action-list button:last-child {
  border-bottom: 0;
}

.action-list button:hover {
  background: var(--surface-2);
}

.action-list button > svg {
  color: var(--muted);
}

.action-list .danger-row strong {
  color: var(--danger);
}

/* Review */
.study-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.study-header {
  display: grid;
  width: min(100% - 32px, 760px);
  min-height: 72px;
  grid-template-columns: 100px 1fr 100px;
  align-items: center;
  gap: 16px;
  margin: 0 auto;
}

.study-exit,
.undo-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.study-exit {
  width: 42px;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.undo-button {
  justify-self: end;
}

.study-count {
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.study-count strong {
  color: var(--text);
}

.study-stage {
  display: grid;
  width: min(100% - 32px, 680px);
  min-height: calc(100dvh - 72px);
  align-content: center;
  justify-items: center;
  margin: 0 auto;
  padding: 20px 0 42px;
}

.study-deck-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.study-deck-label > span {
  margin: 0 5px;
}

.review-card {
  display: grid;
  width: 100%;
  min-height: 440px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.review-card[data-action="reveal"] {
  cursor: pointer;
}

.is-revealed .review-card {
  min-height: 520px;
}

.review-main {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 38px;
  text-align: center;
}

.pronounce-button {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
}

.review-main > h1 {
  margin: 0;
  font-family: var(--font-zh);
  font-size: clamp(76px, 12vw, 112px);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.reveal-prompt {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.question-pinyin {
  margin: 0 0 14px;
  color: var(--primary);
  font-size: 25px;
  font-weight: 650;
}

.answer-content {
  width: 100%;
}

.answer-pinyin {
  margin: 12px 0 0;
  color: var(--primary);
  font-size: 25px;
  font-weight: 650;
}

.answer-meaning {
  margin: 5px 0 0;
  font-size: 20px;
}

.example-block {
  width: min(100%, 480px);
  margin: 28px auto 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  text-align: left;
}

.example-block p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.example-block p[lang] {
  margin-bottom: 6px;
  color: var(--text);
  font-family: var(--font-zh);
  font-size: 19px;
}

.example-block small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}

.card-notes {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.reveal-button {
  width: min(100%, 240px);
  margin-top: 16px;
}

.rating-area {
  width: 100%;
  margin-top: 16px;
}

.rating-area > p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.rating-area .practice-note {
  margin: 12px 0 0;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.rating-button {
  display: grid;
  min-height: 70px;
  place-content: center;
  justify-items: center;
  border: 1px solid var(--border);
  border-top: 4px solid;
  border-radius: 8px;
  background: var(--surface);
}

.rating-button span {
  font-size: 15px;
  font-weight: 700;
}

.rating-button strong {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.rating-button kbd {
  display: none;
}

.rating-again { border-top-color: var(--new); }
.rating-hard { border-top-color: var(--learning); }
.rating-good { border-top-color: var(--review); }
.rating-easy { border-top-color: #47749b; }

.study-empty-page,
.complete-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.study-empty-page > .study-exit {
  position: absolute;
  top: 20px;
  left: 20px;
}

.complete-card {
  width: min(100%, 520px);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: center;
}

.complete-card h1 {
  margin-bottom: 26px;
  font-size: 30px;
}

.complete-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 28px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.complete-stats div {
  padding: 18px 8px;
}

.complete-stats div + div {
  border-left: 1px solid var(--border);
}

.complete-stats strong,
.complete-stats span {
  display: block;
}

.complete-stats strong {
  font-size: 22px;
}

.complete-stats span {
  color: var(--muted);
  font-size: 14px;
}

/* Dialogs */
dialog {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.sheet-dialog {
  width: min(720px, calc(100vw - 24px));
}

.small-dialog,
.confirm-dialog {
  width: min(470px, calc(100vw - 24px));
}

.dialog-form {
  padding: 24px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 25px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 14px;
}

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

.form-grid-primary {
  margin-bottom: 16px;
}

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

.field > span,
.color-field legend {
  font-size: 15px;
  font-weight: 650;
}

.field small {
  color: var(--muted);
  font-size: 14px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.field input,
.field select {
  height: 46px;
  padding: 0 12px;
}

.field textarea {
  min-height: 90px;
  padding: 10px 12px;
  resize: vertical;
}

.field-hanzi input {
  font-family: var(--font-zh);
  font-size: 20px;
}

.field-wide {
  grid-column: 1 / -1;
}

.form-details {
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.form-details summary {
  padding: 16px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.action-spacer {
  flex: 1;
}

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

.color-field {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.color-options input {
  position: absolute;
  opacity: 0;
}

.swatch {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 7px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.swatch-coral { background: #b94b43; }
.swatch-jade { background: #326b5c; }
.swatch-gold { background: #936d1c; }
.swatch-blue { background: #47749b; }
.color-options input:checked + .swatch { border-color: var(--text); }

.install-steps {
  display: grid;
  gap: 16px;
  padding: 0;
  list-style: none;
}

.install-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.install-steps p {
  margin: 0;
  font-size: 16px;
}

.step-number {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 700;
}

.fine-print {
  padding: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

.confirm-dialog {
  text-align: center;
}

.confirm-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--danger);
  font-weight: 700;
}

.confirm-dialog h2 {
  margin-bottom: 8px;
}

.confirm-dialog p {
  color: var(--muted);
  font-size: 15px;
}

.confirm-dialog .dialog-actions {
  justify-content: center;
}

.toast-region {
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 15px;
  border-radius: 7px;
  background: var(--text);
  color: var(--surface);
  font-size: 14px;
  opacity: 0;
  transform: translateY(5px);
  transition: 150ms ease;
}

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

.toast-error {
  background: var(--danger);
  color: #fff;
}

.mobile-nav {
  display: none;
}

@media (max-width: 820px) {
  .sidebar {
    display: none;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: max(24px, env(safe-area-inset-top)) 18px calc(92px + env(safe-area-inset-bottom));
  }

  .mobile-nav {
    position: fixed;
    z-index: 50;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    min-height: calc(66px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(4, 1fr);
    padding: 5px 6px env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .mobile-nav .nav-item {
    display: grid;
    min-height: 58px;
    place-content: center;
    justify-items: center;
    gap: 2px;
    padding: 0;
    background: transparent;
    font-size: 13px;
  }

  .mobile-nav .nav-item svg {
    width: 20px;
  }

  .mobile-nav .nav-item.is-active {
    color: var(--primary);
  }

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

@media (max-width: 620px) {
  .page-header {
    margin-bottom: 22px;
  }

  .page-header h1 {
    font-size: 30px;
  }

  .review-summary {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px;
  }

  .review-total {
    min-width: 0;
  }

  .review-total strong {
    font-size: 58px;
  }

  .start-button {
    width: 100%;
    min-height: 50px;
  }

  .today-count {
    grid-column: 1;
  }

  .deck-row {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding-left: 16px;
  }

  .deck-due {
    grid-row: 2;
    grid-column: 1;
    margin: -8px 0 0;
  }

  .deck-study {
    grid-row: 1 / span 2;
    grid-column: 2;
  }

  .library-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .header-actions .button {
    padding: 0 11px;
  }

  .header-actions .button-secondary {
    display: none;
  }

  .vocab-main {
    min-height: 96px;
    grid-template-columns: 70px minmax(0, 1fr) 78px;
    gap: 10px;
    padding-left: 14px;
  }

  .vocab-hanzi {
    font-size: 30px;
  }

  .vocab-deck {
    display: none;
  }

  .vocab-actions {
    padding-right: 4px;
  }

  .vocab-actions .icon-button:first-child,
  .vocab-actions .icon-button:nth-child(2) {
    display: none;
  }

  .metrics-grid {
    gap: 7px;
  }

  .metric-card {
    min-height: 100px;
  }

  .metric-card strong {
    font-size: 27px;
  }

  .metric-card span {
    font-size: 13px;
  }

  .panel,
  .settings-section {
    padding: 18px;
  }

  .activity-chart {
    height: 230px;
    gap: 6px;
  }

  .install-setting-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .install-setting-card .button {
    width: 100%;
  }

  .action-list {
    margin: 0 -18px -18px;
  }

  .action-list button {
    padding-right: 18px;
    padding-left: 18px;
  }

  .study-header {
    width: calc(100% - 24px);
    min-height: calc(64px + env(safe-area-inset-top));
    grid-template-columns: 44px 1fr 44px;
    padding-top: env(safe-area-inset-top);
  }

  .undo-button span {
    display: none;
  }

  .study-stage {
    width: calc(100% - 24px);
    min-height: calc(100dvh - 64px - env(safe-area-inset-top));
    align-content: start;
    padding: 8px 0 calc(22px + env(safe-area-inset-bottom));
  }

  .review-card {
    min-height: 54dvh;
  }

  .is-revealed .review-card {
    min-height: 59dvh;
  }

  .review-main {
    padding: 54px 20px 30px;
  }

  .review-main > h1 {
    font-size: clamp(70px, 24vw, 100px);
  }

  .example-block {
    margin-top: 22px;
    padding: 15px;
  }

  .rating-buttons {
    gap: 5px;
  }

  .rating-button {
    min-height: 68px;
    padding: 5px 2px;
  }

  .rating-button span {
    font-size: 14px;
  }

  .complete-card {
    padding: 28px 20px;
  }

  .complete-stats strong {
    font-size: 19px;
  }

  .dialog-form {
    padding: 20px 16px;
  }

  .sheet-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin-bottom: 8px;
  }

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

  .field-wide {
    grid-column: 1;
  }

  .color-options {
    gap: 5px;
  }

  .toast-region {
    right: 14px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 14px;
    justify-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
