*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 50% -180px, var(--primary-soft) 0%, transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked {
  overflow: hidden;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

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

img,
svg {
  display: block;
}

[hidden] {
  display: none !important;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
}

/* ---------- App bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--appbar-h);
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.appbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 900;
  font-size: 17px;
  letter-spacing: -0.04em;
}

.appbar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-title.is-brand {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.appbar .icon-btn {
  flex: none;
}

/* ---------- Layout ---------- */

.view {
  min-height: calc(100dvh - var(--appbar-h));
  padding: 18px 20px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom));
  outline: none;
}

body.is-play .view {
  min-height: 100dvh;
  padding: 0;
}

.page {
  animation: page-in 180ms ease-out both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-loading {
  display: grid;
  place-items: center;
  min-height: 50dvh;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--primary-soft-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

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

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

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

.spacer {
  flex: 1;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 14px 30px rgba(0, 143, 88, 0.26);
}

.hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -60px;
  bottom: -90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-eyebrow {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.92;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.hero-counts {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 16px;
  font-size: 14px;
  opacity: 0.94;
}

.hero-counts b {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.hero-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.hero-today {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
}

/* ---------- Stats ---------- */

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

.stat-card {
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-left: 2px;
}

.stat-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* ---------- Progress ring ---------- */

.ring {
  flex: none;
}

.ring-track {
  stroke: var(--primary-soft);
}

.ring-value {
  stroke: var(--primary);
  transition: stroke-dashoffset 500ms ease;
}

.ring-text {
  fill: var(--text);
  font-weight: 900;
  letter-spacing: -0.03em;
}

/* ---------- Horizontal cards ---------- */

.hscroll {
  display: flex;
  gap: 12px;
  margin: 0 -20px;
  padding: 2px 20px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.hscroll::-webkit-scrollbar {
  display: none;
}

.progress-card {
  flex: none;
  width: 118px;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 120ms ease;
}

.progress-card:active {
  transform: scale(0.97);
}

.progress-name {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-meta {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.progress-hint {
  flex: none;
  width: 230px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border: 1px dashed var(--primary-soft-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

/* ---------- Topic cards ---------- */

.topic-grid {
  display: grid;
  gap: 10px;
}

.topic-card {
  position: relative;
  display: block;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 120ms ease, border-color 120ms ease;
}

.topic-card:active {
  transform: scale(0.985);
}

.topic-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 34px;
}

.topic-color {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--primary);
}

.topic-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-desc {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.topic-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border);
}

.topic-kebab {
  position: absolute;
  top: 10px;
  right: 8px;
}

.topic-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.topic-progress .bar {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--primary-soft);
  overflow: hidden;
}

.topic-progress .bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.topic-progress em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Word list ---------- */

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

.word-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.word-row.flash {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.word-main {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.word-term {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.word-meaning {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.word-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.word-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 700;
}

.word-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex: none;
}

.heart-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--muted);
  transition: color 120ms ease, transform 160ms ease;
}

.heart-btn:active {
  transform: scale(0.86);
}

.heart-btn.active {
  color: var(--favorite);
  animation: heart-pop 260ms ease;
}

@keyframes heart-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.chip .icon {
  width: 14px;
  height: 14px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.btn:hover {
  filter: brightness(0.98);
}

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

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

.btn--block {
  width: 100%;
}

.btn--sm {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.btn--ghost {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

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

.btn--outline {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

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

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

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

/* ---------- FAB ---------- */

.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(0, 143, 88, 0.34);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.fab:active {
  transform: scale(0.94);
}

.fab--extended {
  width: auto;
  padding: 0 20px;
}

.fab-root {
  position: fixed;
  right: max(20px, calc(50% - 340px));
  bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom));
  z-index: 70;
}

body.is-play .fab-root,
body.no-nav .fab-root {
  bottom: calc(24px + env(safe-area-inset-bottom));
}

.fab-expand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 160ms ease, transform 160ms ease;
}

.fab-expand.open .fab-actions {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.fab-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.fab-action:active {
  transform: scale(0.97);
}

.fab-main {
  transition: transform 220ms ease;
}

.fab-expand.open .fab-main {
  transform: rotate(45deg);
}

.fab-scrim {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(9, 25, 17, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.fab-expand.open .fab-scrim {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Forms ---------- */

.field {
  margin-bottom: 14px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.field-label .req {
  color: var(--primary);
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.input,
.select {
  height: 48px;
  padding: 0 14px;
}

.textarea {
  min-height: 92px;
  padding: 12px 14px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input.invalid,
.textarea.invalid {
  border-color: var(--danger);
}

.field-error {
  margin-top: 5px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
}

.input-wrap {
  position: relative;
}

.input-wrap .input {
  padding-right: 48px;
}

.input-wrap .icon-btn {
  position: absolute;
  top: 4px;
  right: 4px;
}

.input-icon {
  position: relative;
}

.input-icon > .icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 19px;
  height: 19px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.input-icon .input {
  padding-left: 42px;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 160ms ease;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.switch:has(input:checked) {
  background: var(--primary);
}

.switch:has(input:checked)::after {
  transform: translateX(18px);
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--swatch, var(--primary));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: transform 120ms ease, border-color 120ms ease;
}

.color-swatch.active {
  border-color: var(--text);
  transform: scale(1.05);
}

/* ---------- Empty / error ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 20px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-title {
  font-size: 16px;
  font-weight: 800;
}

.empty-desc {
  margin: 4px 0 16px;
  max-width: 300px;
  color: var(--muted);
  font-size: 13px;
}

.error-box {
  padding: 16px;
  border: 1px solid var(--danger-soft);
  border-radius: 16px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Bottom nav ---------- */

.bottomnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  max-width: 720px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 4px 10px env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transform: translateX(-50%);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 28px;
  border-radius: 999px;
  transition: background 140ms ease, color 140ms ease;
}

.nav-icon .icon {
  width: 22px;
  height: 22px;
}

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

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

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

body.is-play .toasts {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

body.no-nav .toasts {
  bottom: calc(24px + env(safe-area-inset-bottom));
}

body.has-fab .toasts {
  bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}

body.has-fab.no-nav .toasts {
  bottom: calc(90px + env(safe-area-inset-bottom));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #17251e;
  color: #f2fbf7;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #7ce8b8;
}

.toast--error .toast-icon {
  color: #ff9aa3;
}

.toast--info .toast-icon {
  color: #a9d8ff;
}

.toast-message {
  flex: 1;
  min-width: 0;
}

.toast-action {
  flex: none;
  pointer-events: auto;
  margin-left: 4px;
  color: #8ff0c4;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

/* ---------- Sheets / dialogs ---------- */

.sheet-backdrop,
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(9, 25, 17, 0.45);
  opacity: 0;
  transition: opacity 180ms ease;
  overflow: hidden;
}

.sheet-backdrop.open,
.dialog-backdrop.open {
  opacity: 1;
}

.sheet {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: 90dvh;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-backdrop.open .sheet {
  transform: none;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 8px auto 2px;
  border-radius: 999px;
  background: var(--border);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px 4px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.sheet-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.sheet-body {
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.dialog-backdrop {
  align-items: center;
  padding: 24px;
}

.dialog {
  width: min(370px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
  transform: scale(0.96);
  transition: transform 180ms ease;
}

.dialog-backdrop.open .dialog {
  transform: none;
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.dialog-text {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-line;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ---------- Login ---------- */

.login-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.login-page::before,
.login-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: var(--primary-soft);
  opacity: 0.7;
  filter: blur(2px);
}

.login-page::before {
  width: 260px;
  height: 260px;
  top: -110px;
  right: -90px;
}

.login-page::after {
  width: 220px;
  height: 220px;
  bottom: -120px;
  left: -100px;
  background: var(--primary-soft-2);
  opacity: 0.45;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  padding: 30px 24px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
  text-align: center;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: var(--gradient);
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.06em;
  box-shadow: 0 12px 26px rgba(0, 143, 88, 0.3);
}

.login-title {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.login-sub {
  margin: 4px 0 24px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.login-form {
  text-align: left;
}

.login-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* ---------- Search ---------- */

.search-bar {
  position: relative;
}

.search-bar .icon {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 20px;
  height: 20px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-bar .input {
  height: 50px;
  padding-left: 45px;
  padding-right: 44px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-clear {
  position: absolute;
  top: 5px;
  right: 5px;
}

.result-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.result-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 120ms ease;
}

.result-card:active {
  transform: scale(0.99);
}

.result-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.result-term {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result-meaning {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.result-meta .tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.result-example {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.5;
}

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

mark {
  border-radius: 4px;
  background: color-mix(in srgb, var(--highlight) 55%, transparent);
  color: inherit;
  padding: 0 1px;
}

.recent {
  margin-top: 18px;
}

.recent-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

/* ---------- Study setup ---------- */

.setup-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.setup-row:last-child {
  border-bottom: none;
}

.setup-label {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.setup-value {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
}

.seg button {
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.seg button.active {
  background: var(--surface);
  color: var(--primary-strong);
  box-shadow: 0 2px 8px rgba(0, 80, 45, 0.12);
}

.setup-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.setup-note b {
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Flash cards ---------- */

.play-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top)) 20px calc(18px + env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 400px at 50% 0%, var(--primary-soft) 0%, transparent 70%),
    var(--bg);
}

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

.play-count {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 240ms ease;
}

.flash {
  flex: 1;
  min-height: 360px;
  margin: 18px 0;
  perspective: 1400px;
  cursor: pointer;
}

.flash-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  transform-style: preserve-3d;
  transition: transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flash.is-flipped .flash-inner {
  transform: rotateY(180deg);
}

.flash-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-y: auto;
}

.flash-back {
  transform: rotateY(180deg);
  justify-content: flex-start;
  padding-top: 34px;
}

.flash-term {
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-align: center;
  overflow-wrap: anywhere;
}

.flash-pron {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.flash-hint {
  position: absolute;
  bottom: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.flash-label {
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.flash-meaning {
  font-size: clamp(21px, 6vw, 28px);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.flash-examples {
  width: 100%;
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.flash-example {
  padding: 11px 13px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
}

.flash-example .translation {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.study-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn--dont {
  background: var(--surface-2);
  color: var(--text);
}

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

.study-actions .btn {
  height: 54px;
  font-size: 15px;
}

.study-actions .btn:disabled {
  opacity: 0.4;
}

/* ---------- Result ---------- */

.result-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-title {
  margin: 6px 0 0;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.result-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.result-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

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

.result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.result-item .marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.result-item.wrong .marker {
  background: var(--danger-soft);
  color: var(--danger);
}

.result-item-body {
  flex: 1;
  min-width: 0;
}

.result-item-term {
  font-size: 14px;
  font-weight: 800;
}

.result-item-meaning {
  color: var(--muted);
  font-size: 12px;
}

.result-item-example {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

/* ---------- Stats ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 142px;
  padding: 14px 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  position: relative;
  width: 100%;
  max-width: 26px;
  height: 96px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.chart-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  transition: height 500ms ease;
}

.chart-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.chart-pct {
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.topic-stat {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topic-stat-body {
  flex: 1;
  min-width: 0;
}

.topic-stat-name {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-stat-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* ---------- Settings ---------- */

.settings-group {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-title {
  margin: 22px 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}

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

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

.setting-desc {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.setting-row .seg {
  flex: none;
}

.settings-form {
  padding: 16px;
}

.info-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.info-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}

.info-row span:first-child {
  color: var(--muted);
  font-weight: 600;
}

.info-row span:last-child {
  text-align: right;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------- Skeleton ---------- */

.skeleton {
  border-radius: 18px;
  background: linear-gradient(
    100deg,
    var(--surface-2) 20%,
    var(--surface) 40%,
    var(--surface-2) 60%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-card {
  height: 92px;
  margin-bottom: 10px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Responsive ---------- */

@media (min-width: 620px) {
  .view {
    padding: 24px 28px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
  }

  .hscroll {
    margin: 0 -28px;
    padding-inline: 28px;
  }

  .hero {
    padding: 24px 26px;
  }

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

  .topic-grid .empty {
    grid-column: 1 / -1;
  }

  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }

  .sheet {
    max-width: 540px;
    max-height: 84dvh;
    border-radius: 28px;
  }

  .login-card {
    padding: 36px 34px;
  }

  .result-actions {
    grid-template-columns: 1fr 1fr;
  }

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

@media (min-width: 900px) {
  .flash {
    min-height: 430px;
  }
}

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

/* ---------- v0.3 additions ---------- */

.topic-main {
  display: block;
}

.topic-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topic-hero-body {
  flex: 1;
  min-width: 0;
}

.topic-hero-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.topic-hero-desc {
  margin: 3px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-hero-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.topic-hero-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border);
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 14px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  transition: background 120ms ease;
}

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

.action-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.action-item.danger .action-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.action-item.danger .action-label {
  color: var(--danger);
}

.action-chevron {
  margin-left: auto;
  color: var(--muted);
}

.example-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.example-row {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.example-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.example-num {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.example-row .icon-btn {
  width: 28px;
  height: 28px;
}

.example-row .input {
  height: 42px;
  margin-top: 6px;
  background: var(--surface);
  font-size: 13px;
}

.add-example {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 42px;
  border: 1px dashed var(--primary-soft-2);
  border-radius: 14px;
  background: transparent;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
}

.add-example:disabled {
  opacity: 0.5;
  cursor: default;
}

.setup-select {
  width: auto;
  max-width: 200px;
  height: 40px;
  padding: 0 34px 0 12px;
  border-radius: 12px;
  font-size: 13px;
}

.spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
  flex: none;
}

.btn .spinner {
  border-color: rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
}

.btn--ghost .spinner,
.btn--outline .spinner,
.btn--danger .spinner {
  border-color: var(--primary-soft-2);
  border-top-color: var(--primary);
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.result-item .heart-btn {
  flex: none;
}

body.is-login .view {
  min-height: 100dvh;
  padding: 0;
}
