:root {
  color-scheme: light;
  --bg: #e9f6ff;
  --bg-deep: #d9edff;
  --surface: rgba(230, 245, 255, 0.62);
  --surface-strong: rgba(240, 250, 255, 0.86);
  --surface-soft: rgba(216, 238, 255, 0.46);
  --text: #0d223f;
  --muted: #4d6484;
  --primary: #2f86f6;
  --primary-strong: #1f6fd6;
  --accent: #1f9ec2;
  --danger: #be4047;
  --ok: #2f8c56;
  --outline: rgba(33, 82, 130, 0.2);
  --outline-strong: rgba(28, 74, 122, 0.3);
  --glass-shadow: 0 18px 60px rgba(0, 0, 0, 0.14);
  --glass-shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.10);
  --glass-bg: color-mix(in srgb, var(--tg-theme-bg-color, #d9edff) 72%, white 28%);
  --glass-surface: rgba(224, 242, 255, 0.58);
  --glass-surface-strong: rgba(238, 249, 255, 0.78);
  --glass-stroke: rgba(255, 255, 255, 0.72);
  --glass-stroke-dark: rgba(41, 94, 148, 0.1);
  --blur: 26px;
  --r-lg: 26px;
  --r-md: 18px;
  --card-shadow: 0 10px 24px rgba(32, 88, 146, 0.12);
  --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --tg-bg-color: var(--bg);
  --tg-text-color: var(--text);
  --tg-hint-color: var(--muted);
  --tg-secondary-bg-color: rgba(224, 241, 255, 0.68);
  --tg-button-color: var(--primary);
  --tg-button-text-color: #ffffff;
  --tg-safe-top: 0px;
  --tg-safe-bottom: 0px;
  --tg-safe-left: 0px;
  --tg-safe-right: 0px;
  --tg-content-safe-top: 0px;
  --tg-content-safe-bottom: 0px;
  --tg-content-safe-left: 0px;
  --tg-content-safe-right: 0px;
  --safe-area-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-top));
  --safe-area-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-bottom));
  --safe-area-left: max(env(safe-area-inset-left, 0px), var(--tg-content-safe-left));
  --safe-area-right: max(env(safe-area-inset-right, 0px), var(--tg-content-safe-right));
  --shell-max-width: 760px;
  --shell-padding: 16px;
  --panel-padding: 14px;
  --surface-gap: 12px;
  --modal-padding: 14px;
  --modal-max-width: 520px;
  --practice-result-max-width: 560px;
  --card-stage-min-height: min(56vh, 360px);
  --flashcard-max-width: 520px;
  --flashcard-max-height: min(56vh, 360px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overscroll-behavior: none;
}

html.swipe-lock,
body.swipe-lock {
  overflow: hidden;
}

body {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  color: var(--tg-text-color);
  background:
    radial-gradient(110% 85% at 0% 0%, rgba(255, 255, 255, 0.84) 0%, transparent 56%),
    radial-gradient(95% 80% at 100% 10%, rgba(168, 215, 255, 0.52) 0%, transparent 58%),
    radial-gradient(90% 75% at 45% 100%, rgba(195, 231, 255, 0.58) 0%, transparent 60%),
    linear-gradient(180deg, var(--glass-bg) 0%, var(--bg-deep) 100%);
  display: flex;
  justify-content: center;
  --safe-top-inset: var(--safe-area-top);
  --safe-bottom-inset: var(--safe-area-bottom);
  --safe-left-inset: var(--safe-area-left);
  --safe-right-inset: var(--safe-area-right);
  --mobile-top-offset: 0px;
  padding:
    calc(14px + var(--safe-top-inset) + var(--mobile-top-offset))
    calc(14px + var(--safe-right-inset))
    calc(14px + var(--safe-bottom-inset))
    calc(14px + var(--safe-left-inset));
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.bg-glow {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.34;
  animation: drift 22s ease-in-out infinite alternate;
}

.bg-glow-a {
  width: 220px;
  height: 220px;
  background: rgba(144, 206, 255, 0.9);
  top: -80px;
  left: -60px;
}

.bg-glow-b {
  width: 240px;
  height: 240px;
  background: rgba(170, 224, 255, 0.86);
  bottom: -95px;
  right: -65px;
}

.app-shell {
  width: min(var(--shell-max-width), 100%);
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  position: relative;
  z-index: 2;
  border-radius: clamp(18px, 3vw, 24px);
  border: 1px solid var(--outline);
  background: linear-gradient(150deg, var(--surface) 0%, var(--surface-strong) 100%);
  box-shadow: var(--inner-glow), var(--glass-shadow);
  padding: var(--shell-padding);
  backdrop-filter: blur(16px) saturate(1.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: -45% -20% auto;
  height: 54%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: nowrap;
}

.brand {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: -0.01em;
  font-size: clamp(1.42rem, 3.35vw, 1.92rem);
}

.eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  font-size: 0.67rem;
  letter-spacing: 0.09em;
  color: var(--tg-hint-color);
}

.badges {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  margin-left: auto;
  min-width: 0;
  gap: 6px;
}

.badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  color: var(--text);
  background: rgba(255, 255, 255, 0.52);
  box-shadow: var(--inner-glow);
}

.badge-button {
  cursor: pointer;
  max-width: min(54vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.badge-button:hover {
  transform: translateY(-1px);
  border-color: var(--outline-strong);
  box-shadow: var(--inner-glow), 0 6px 14px rgba(26, 38, 56, 0.12);
}

.badge-button:focus-visible {
  outline: 2px solid rgba(46, 117, 215, 0.6);
  outline-offset: 2px;
}

.badge-outline {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.36);
}

.tabs {
  margin: 2px 0 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.global-error {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-area-bottom));
  transform: translateX(-50%);
  z-index: 20;
  margin: 0;
  border: 1px solid rgba(255, 120, 130, 0.35);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 240, 242, 0.55);
  color: #7e1f2c;
  font-size: 0.82rem;
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  box-shadow: var(--glass-shadow-soft);
  max-width: min(92vw, 520px);
  display: inline-flex;
  align-items: center;
}
.global-error::before {
  content: "⚠";
  margin-right: 6px;
}


.auth-gate {
  margin: 0 0 12px;
  border: 1px solid rgba(46, 117, 215, 0.32);
  border-radius: 16px;
  padding: 12px;
  background: rgba(228, 239, 255, 0.58);
  box-shadow: var(--inner-glow);
  width: 100%;
}

.auth-gate h2 {
  margin: 7px 0 6px;
  font-size: 1.04rem;
}

.auth-gate-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-gate-actions {
  margin-top: 10px;
}

.tab {
  border: 1px solid var(--outline);
  border-radius: 13px;
  padding: 10px;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.36));
  box-shadow: var(--inner-glow);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.tab:hover {
  transform: translateY(-1px);
  box-shadow: var(--inner-glow), 0 6px 14px rgba(26, 38, 56, 0.12);
}

.tab.is-active {
  color: var(--primary-strong);
  border-color: rgba(46, 117, 215, 0.45);
  background: linear-gradient(165deg, rgba(237, 245, 255, 0.86), rgba(221, 236, 255, 0.58));
  box-shadow: var(--inner-glow), 0 8px 18px rgba(46, 117, 215, 0.18);
}

main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  display: none;
  animation: fade-in 220ms ease;
}

.view.is-active {
  display: grid;
  flex: 1 1 auto;
  gap: var(--surface-gap);
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  padding-bottom: calc(var(--surface-gap) + 2px);
  scrollbar-width: thin;
}

.view.is-active::-webkit-scrollbar {
  width: 6px;
}

.view.is-active::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(85, 129, 187, 0.24);
}

#view-words.is-active {
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  padding-bottom: 0;
}

.hero-card,
.block,
.question-card {
  border: 1px solid var(--outline);
  border-radius: 18px;
  padding: var(--panel-padding);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.32));
  box-shadow: var(--inner-glow), var(--card-shadow);
  backdrop-filter: blur(12px);
  min-width: 0;
}

.question-card {
  border-color: rgba(31, 48, 74, 0.2);
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
}

.hero-card h2,
.question-card h3 {
  margin: 7px 0 9px;
  line-height: 1.18;
}

#question-term {
  margin-bottom: 4px;
  font-size: clamp(1.28rem, 3.5vw, 1.8rem);
}

#question-prompt {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

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

.hero-card-compact {
  min-height: 182px;
}

#view-home.is-active {
  grid-template-columns: minmax(0, 1fr);
}

.home-hero-card {
  grid-area: auto;
  padding: 18px 14px 15px;
  text-align: center;
}

.home-hero-card .eyebrow {
  text-align: center;
}

.home-hero-mainline {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  margin: 8px 0 10px;
  flex-wrap: wrap;
}

.home-hero-count {
  font-size: clamp(3rem, 14vw, 4.6rem);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: var(--primary);
}

.home-hero-copy {
  display: grid;
  gap: 5px;
  justify-items: center;
}

.home-hero-copy h2 {
  margin: 0;
  font-size: clamp(1.52rem, 6.7vw, 2.28rem);
}

.home-hero-copy p {
  margin: 0;
}

.home-hero-cta {
  width: 100%;
  min-height: 52px;
  margin-top: 14px;
  font-size: 1.06rem;
}

.home-hero-estimate {
  margin-top: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.home-stats-card {
  grid-area: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, auto);
  align-items: stretch;
  gap: 0;
  padding: 0;
  min-height: 88px;
  overflow: hidden;
}

.home-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  min-width: 0;
}

.home-stat + .home-stat {
  border-left: 1px solid rgba(31, 48, 74, 0.08);
}

.home-stat-icon,
.home-section-icon {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  color: rgba(57, 109, 193, 0.78);
  background: rgba(118, 165, 233, 0.12);
  box-shadow: var(--inner-glow);
}

.home-section-icon {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
}

.home-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-stat-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.home-stat-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.1;
}

.home-stat-copy strong {
  font-size: 1.24rem;
  line-height: 1;
  font-weight: 700;
}

.home-next-card {
  grid-area: auto;
  display: grid;
  gap: 14px;
}

.home-week-card {
  grid-area: auto;
  display: grid;
  gap: 12px;
}

.home-attention-card {
  grid-area: auto;
}

.home-recent-card {
  grid-area: auto;
}

.home-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.home-section-heading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.home-section-heading h3 {
  margin: 0;
  font-size: 1.12rem;
}

.home-next-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.home-next-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.home-next-heading {
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.2;
}

.home-next-subtitle,
.home-week-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
}

.home-inline-btn {
  width: auto;
  min-width: 96px;
}

.home-inline-btn--compact {
  min-width: 0;
  padding: 8px 12px;
}

.home-week-progress-text {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  font-size: 0.8rem;
}

.home-progress-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(135, 166, 217, 0.18);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.42);
}

.home-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(105, 157, 235, 0.9), rgba(150, 191, 248, 0.95));
}

.home-block-header {
  margin-bottom: 6px;
}

.home-focus-list,
.home-recent-list {
  gap: 0;
}

.home-focus-list li,
.home-recent-list li {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.home-focus-list li + li,
.home-recent-list li + li {
  border-top: 1px solid rgba(31, 48, 74, 0.08);
}

.home-list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 2px;
  min-width: 0;
}

.home-list-main {
  min-width: 0;
  flex: 1;
}

.home-list-main strong {
  font-size: 1.02rem;
  line-height: 1.24;
}

.home-list-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.36;
}

.home-list-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.38;
}

.home-list-empty {
  padding: 10px 2px 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.home-recent-list .word-row {
  align-items: flex-start;
  flex-wrap: wrap;
}

.home-focus-list .word-level,
.home-recent-list .word-level {
  margin-left: auto;
}

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.block-header--vocabulary {
  gap: 10px;
  flex-wrap: wrap;
}

.block-header h3 {
  margin: 0;
  font-size: 1rem;
}

.section-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.section-heading--inline {
  flex-wrap: wrap;
}

.block-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.modal-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(31, 48, 74, 0.12);
}

.modal-section-header {
  margin-bottom: 6px;
}

.modal-section-copy {
  margin-bottom: 10px;
}

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

.settings-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tg-hint-color);
}

.language-select {
  width: 100%;
}

.counter {
  font-family: "IBM Plex Mono", monospace;
  border: 1px solid var(--outline);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.55);
}

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

.chip {
  border: 1px solid var(--outline);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.5);
}

.question-language-meta,
.modal-chip-list,
.word-language-chips {
  margin-bottom: 10px;
}

.word-language-chips {
  margin-top: 8px;
}

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

#view-words .block {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

#word-list {
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  padding-right: 4px;
}

.stack-list li {
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: var(--inner-glow);
}

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

.manual-word-settings-panel {
  margin-bottom: 2px;
  padding: 10px;
  border: 1px solid var(--outline);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.46);
}

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

.manual-word-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.manual-word-actions .feedback {
  margin: 0;
  min-height: 1rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: var(--modal-padding);
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.38);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: min(var(--modal-max-width), 100%);
  max-height: calc(100dvh - (var(--modal-padding) * 2));
  overflow: auto;
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.66));
  box-shadow: var(--inner-glow), var(--glass-shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close-btn {
  width: auto;
}

.word-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.auth-options-card {
  width: min(460px, 100%);
}

.entry-settings-card {
  width: min(460px, 100%);
}

.entry-settings-summary {
  margin-bottom: 12px;
}

.entry-settings-summary h3 {
  margin: 6px 0 0;
  font-size: 1.12rem;
}

.static-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  color: var(--text);
  font-weight: 600;
  background: rgba(244, 250, 255, 0.72);
}

.entry-settings-actions {
  margin-top: 12px;
}

.practice-result-card {
  width: min(var(--practice-result-max-width), 100%);
}

.practice-result-card h2 {
  margin: 6px 0 4px;
}

.practice-result-card.is-ok h2 {
  color: var(--ok);
}

.practice-result-card.is-bad h2 {
  color: var(--danger);
}

.practice-result-detail {
  margin: 0;
  color: var(--muted);
}

.practice-result-media {
  margin-top: 2px;
}

.practice-result-media.is-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.practice-result-media.is-inline .practice-result-detail {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.practice-result-image {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.practice-result-answer {
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid rgba(190, 64, 71, 0.3);
  background: rgba(255, 240, 241, 0.75);
  color: var(--danger);
  font-size: 0.88rem;
  line-height: 1.45;
}

.practice-coachmark {
  margin: 0;
  justify-self: start;
  width: min(100%, 420px);
}

.practice-coachmark p {
  margin: 0;
}

body.modal-open {
  overflow: hidden;
}

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

.word-row-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.word-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.word-row-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.secondary-btn.word-row-action-btn,
.danger-btn.word-row-action-btn {
  width: auto;
}

.word-row-action-btn--settings {
  min-width: 0;
}

.word-row-action-btn--delete {
  padding-inline: 9px 11px;
}

.word-row-action-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.word-row strong {
  font-size: 1rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.word-level {
  font-family: "IBM Plex Mono", monospace;
  color: var(--accent);
  font-size: 0.75rem;
  line-height: 1;
  border: 1px solid rgba(63, 114, 175, 0.18);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(63, 114, 175, 0.08);
}

.word-meaning,
.word-context {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.word-context {
  font-size: 0.82rem;
}

.question-meta {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 9px;
}

.question-progress-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  width: min(100%, 460px);
}

.chapter-progress {
  position: relative;
  display: block;
  flex: 1;
  min-height: 34px;
  padding-bottom: 14px;
  overflow: visible;
}

.chapter-progress::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  height: 2px;
  border-radius: 999px;
  background: rgba(31, 48, 74, 0.2);
  transform: translateY(-50%);
}

.chapter-progress__fill {
  position: absolute;
  left: 0;
  top: 8px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(29, 140, 156, 0.9), rgba(46, 117, 215, 0.86));
  z-index: 0;
  transform: translateY(-50%);
  transition: width 240ms ease;
}

.chapter-progress__checkpoint {
  position: absolute;
  top: 8px;
  z-index: 1;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(31, 48, 74, 0.32);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--inner-glow);
  transform: translate(-50%, -50%);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.chapter-progress__checkpoint-label {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 1.6em;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1;
}

.chapter-progress__checkpoint.is-done {
  border-color: rgba(46, 117, 215, 0.55);
  background: rgba(46, 117, 215, 0.88);
  box-shadow: 0 0 0 2px rgba(46, 117, 215, 0.15);
}

.chapter-progress__checkpoint.is-current {
  border-color: rgba(29, 140, 156, 0.56);
  background: rgba(29, 140, 156, 0.96);
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 0 0 3px rgba(29, 140, 156, 0.14);
}

.pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.69rem;
  border-radius: 999px;
  border: 1px solid var(--outline);
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.5);
}

.answer-area {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.practice-hint-row {
  display: grid;
  gap: 6px;
  align-content: start;
}

.practice-hint-inline {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.practice-hint-word {
  display: inline;
  padding: 0 0 1px;
  width: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
  box-shadow: none;
}

.practice-hint-word:hover {
  transform: none;
  background: none;
  color: #1a5eb3;
}

.practice-hint-word:disabled {
  opacity: 0.55;
  cursor: default;
  text-decoration: none;
}

.practice-hint-word:focus-visible {
  outline: 2px solid rgba(46, 117, 215, 0.32);
  outline-offset: 4px;
  border-radius: 6px;
}

.practice-hint-popover {
  justify-self: start;
  max-width: min(100%, 320px);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(46, 117, 215, 0.22);
  background: rgba(242, 247, 255, 0.95);
  box-shadow: var(--inner-glow), 0 10px 24px rgba(26, 38, 56, 0.08);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
}

.choice-btn {
  border: 1px solid var(--outline-strong);
  border-radius: 13px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.44));
  box-shadow: var(--inner-glow);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.choice-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--inner-glow), 0 7px 15px rgba(26, 38, 56, 0.11);
}

.choice-btn.is-selected {
  border-color: rgba(46, 117, 215, 0.46);
  background: linear-gradient(160deg, rgba(223, 237, 255, 0.82), rgba(255, 255, 255, 0.66));
  box-shadow: var(--inner-glow), 0 0 0 2px rgba(46, 117, 215, 0.14);
}

.cloze-choice-chip {
  cursor: grab;
}

.cloze-choice-chip:active {
  cursor: grabbing;
}

.cloze-choice-chip.is-dragging {
  opacity: 0.55;
  transform: scale(0.98);
}

.choice-btn:disabled,
.match-token:disabled,
.primary-btn:disabled,
.secondary-btn:disabled,
.text-input:disabled,
.tab:disabled {
  opacity: 0.66;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.match-hint {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.77rem;
  color: var(--muted);
}

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

.match-column {
  border: 1px solid var(--outline);
  border-radius: 13px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: var(--inner-glow);
}

.match-column-title {
  margin: 0 0 7px;
  font-size: 0.71rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
}

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

.match-token {
  border: 1px solid var(--outline-strong);
  border-radius: 11px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--inner-glow);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.match-token:hover {
  transform: translateY(-1px);
}

.match-token.is-active {
  border-color: rgba(29, 140, 156, 0.45);
  background: rgba(225, 248, 251, 0.78);
  box-shadow: var(--inner-glow), 0 0 0 2px rgba(29, 140, 156, 0.15);
}

.match-token.is-linked {
  border-color: rgba(46, 117, 215, 0.45);
  background: rgba(228, 239, 255, 0.76);
}

.match-token.is-locked {
  border-color: rgba(31, 48, 74, 0.24);
  background: rgba(240, 244, 249, 0.82);
  color: rgba(24, 34, 49, 0.65);
  opacity: 0.72;
  cursor: default;
  transform: none;
}

.match-token.is-locked:hover {
  transform: none;
}

.match-token.is-error {
  border-color: rgba(190, 64, 71, 0.5);
  background: rgba(255, 231, 233, 0.9);
  box-shadow: var(--inner-glow), 0 0 0 2px rgba(190, 64, 71, 0.14);
  animation: match-shake 220ms ease-in-out 4;
}

.match-token-meaning {
  font-size: 0.84rem;
}

.match-pairs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.match-pair-row {
  border: 1px dashed rgba(31, 48, 74, 0.28);
  border-radius: 11px;
  padding: 7px 9px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.77rem;
  background: rgba(255, 255, 255, 0.52);
}

.cloze-line {
  border: 1px solid rgba(31, 48, 74, 0.21);
  border-radius: 13px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--inner-glow);
}

.cloze-inline-text {
  margin: 0;
  line-height: 1.66;
  font-size: 0.97rem;
}

.text-input.cloze-inline-input {
  display: inline-block;
  width: auto;
  min-width: 4ch;
  max-width: min(26ch, 70vw);
  margin: 0 6px;
  padding: 7px 8px;
  border-radius: 10px;
  vertical-align: baseline;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
}

.cloze-slot {
  display: inline-flex;
  min-width: 76px;
  justify-content: center;
  align-items: center;
  margin: 0 6px;
  padding: 4px 11px;
  border-radius: 10px;
  border: 1px dashed rgba(31, 48, 74, 0.34);
  background: rgba(255, 255, 255, 0.8);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.cloze-slot.is-filled {
  border-style: solid;
  border-color: rgba(46, 117, 215, 0.42);
  box-shadow: 0 0 0 2px rgba(46, 117, 215, 0.12);
}

.cloze-slot.is-drag-over {
  border-style: solid;
  border-color: rgba(29, 140, 156, 0.5);
  background: rgba(225, 248, 251, 0.84);
  box-shadow: 0 0 0 3px rgba(29, 140, 156, 0.16);
}

.cloze-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.cloze-options .choice-btn {
  width: fit-content;
  max-width: 100%;
  flex: 0 0 auto;
}

.text-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--outline-strong);
  padding: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--inner-glow);
}

.text-input:focus {
  outline: none;
  border-color: rgba(46, 117, 215, 0.5);
  box-shadow: var(--inner-glow), 0 0 0 3px rgba(46, 117, 215, 0.14);
}

.actions-row {
  margin-top: 11px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.onboarding-step-actions {
  margin-top: auto;
}

.onboarding-back-row {
  display: flex;
  align-items: center;
}

.onboarding-back-btn {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.onboarding-step-actions .primary-btn,
.onboarding-step-actions .secondary-btn {
  flex: 1 1 0;
}

.modal-actions {
  flex-direction: column;
  align-items: flex-end;
}

.modal-actions .primary-btn,
.modal-actions .secondary-btn {
  min-width: 120px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border-radius: 12px;
  padding: 10px 14px;
  border: 0;
  cursor: pointer;
  font-weight: 650;
  font-family: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-btn {
  border: 1px solid rgba(255, 255, 255, 0.34);
  color: var(--tg-button-text-color);
  background: linear-gradient(180deg, #4b88de 0%, #2e75d7 60%, #215fb9 100%);
  box-shadow: 0 8px 18px rgba(46, 117, 215, 0.26);
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  border: 1px solid var(--outline);
  color: var(--text);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--inner-glow), 0 6px 14px rgba(26, 38, 56, 0.09);
}

.secondary-btn:hover {
  transform: translateY(-1px);
}

.danger-btn {
  border: 1px solid rgba(190, 64, 71, 0.28);
  color: var(--danger);
  background: rgba(255, 240, 241, 0.78);
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 650;
}

.danger-btn:hover {
  background: rgba(255, 232, 234, 0.92);
}

.feedback {
  margin: 10px 0 0;
  min-height: 1.1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.feedback.is-info {
  color: var(--accent);
}

.feedback.is-ok {
  color: var(--ok);
  font-weight: 600;
}

.feedback.is-bad {
  color: var(--danger);
  font-weight: 600;
}

#practice-feedback:empty {
  display: none;
}

.fireworks-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.firework-particle {
  position: absolute;
  width: var(--size, 5px);
  height: var(--size, 5px);
  left: var(--origin-x, 50%);
  top: var(--origin-y, 60%);
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.42);
  transform: translate(-50%, -50%) scale(0.35);
  opacity: 0;
  animation: firework-pop 620ms ease-out forwards;
  animation-delay: var(--delay, 0ms);
}

.hidden {
  display: none !important;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(16px, -12px, 0);
  }
}

@keyframes firework-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1);
  }
}

@keyframes match-shake {
  0% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px) rotate(-1deg);
  }

  50% {
    transform: translateX(4px) rotate(1deg);
  }

  75% {
    transform: translateX(-3px) rotate(-0.7deg);
  }

  100% {
    transform: translateX(0);
  }
}


.glass {
  background: var(--glass-surface);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--glass-shadow-soft);
}

.practice-mode-picker {
  margin-bottom: 10px;
  padding: 10px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--glass-stroke-dark);
  border-radius: 999px;
  padding: 4px;
}

.mode-switch .secondary-btn {
  width: 100%;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.32);
}

.mode-switch .secondary-btn.is-active {
  border-color: var(--glass-stroke);
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--inner-glow), 0 8px 18px rgba(26, 38, 56, 0.08);
}


.flashcards-screen {
  display: grid;
  gap: 14px;
}

.flashcards-root {
  height: 100%;
  overscroll-behavior: none;
  /* Keep horizontal swipe under JS control; allow only native vertical panning. */
  touch-action: pan-y;
}

.meta-row {
  display: flex;
  justify-content: flex-start;
}

.card-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: var(--card-stage-min-height);
}

#flashcards-hero,
#onboarding-guided-card {
  width: min(100%, var(--flashcard-max-width));
  height: var(--flashcard-max-height);
  display: grid;
  place-items: center;
  padding: 26px;
  outline: none;
  transform-style: preserve-3d;
  --flashcards-flip-rot: 0deg;
  --flashcards-swipe-x: 0px;
  --flashcards-swipe-rot: 0deg;
  --flashcards-hover-y: 0px;
  transform: translate3d(var(--flashcards-swipe-x), var(--flashcards-hover-y), 0)
    rotate(var(--flashcards-swipe-rot))
    rotateY(var(--flashcards-flip-rot));
  transition:
    transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1),
    box-shadow 220ms ease,
    border-color 180ms ease,
    background 180ms ease,
    opacity 200ms ease;
  will-change: transform;
}

#flashcards-hero.is-flipped,
#onboarding-guided-card.is-flipped {
  --flashcards-flip-rot: 180deg;
}

#flashcards-hero.is-flipped .card-text,
#onboarding-guided-card.is-flipped .card-text {
  transform: rotateY(180deg);
}

#flashcards-hero.is-swiping,
#onboarding-guided-card.is-swiping {
  transition:
    box-shadow 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

#flashcards-hero.swipe-return,
#onboarding-guided-card.swipe-return {
  transition:
    transform 170ms cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

#flashcards-hero.swipe-left,
#onboarding-guided-card.swipe-left {
  border-color: rgba(190, 64, 71, 0.5);
  box-shadow:
    0 24px 64px rgba(190, 64, 71, 0.2),
    var(--glass-shadow);
  background:
    radial-gradient(1200px 500px at 20% 10%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.45), rgba(255, 225, 230, 0.65));
}

#flashcards-hero.swipe-right,
#onboarding-guided-card.swipe-right {
  border-color: rgba(47, 140, 86, 0.5);
  box-shadow:
    0 24px 64px rgba(47, 140, 86, 0.2),
    var(--glass-shadow);
  background:
    radial-gradient(1200px 500px at 20% 10%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.45), rgba(222, 245, 231, 0.7));
}

#flashcards-hero.swipe-commit-left,
#flashcards-hero.swipe-commit-right,
#onboarding-guided-card.swipe-commit-left,
#onboarding-guided-card.swipe-commit-right {
  transition:
    transform 190ms cubic-bezier(0.18, 0.84, 0.44, 1),
    opacity 190ms ease,
    box-shadow 190ms ease;
}

#flashcards-hero.swipe-commit-left,
#onboarding-guided-card.swipe-commit-left {
  --flashcards-swipe-x: -180px;
  --flashcards-swipe-rot: -12deg;
  opacity: 0;
}

#flashcards-hero.swipe-commit-right,
#onboarding-guided-card.swipe-commit-right {
  --flashcards-swipe-x: 180px;
  --flashcards-swipe-rot: 12deg;
  opacity: 0;
}

.flashcard.ghost {
  position: absolute;
  z-index: 0;
  transform: translateY(14px) scale(0.975);
  opacity: 0.35;
  filter: saturate(0.95);
  pointer-events: none;
}

#flashcards-hero.flashcard,
#onboarding-guided-card.flashcard {
  z-index: 1;
}

.card-text {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.08;
  text-align: center;
  color: #0f172a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.48);
  text-wrap: balance;
  max-width: 100%;
}

.below-card {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.actions.flashcards-actions-row {
  display: flex;
  gap: 12px;
  width: min(100%, var(--flashcard-max-width));
}

.actions.flashcards-actions-row .pill {
  flex: 1;
  border-radius: 999px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.10);
  font-weight: 650;
}

.flashcard {
  position: relative;
  border-radius: var(--r-lg);
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(calc(var(--blur) + 8px)) saturate(160%);
  -webkit-backdrop-filter: blur(calc(var(--blur) + 8px)) saturate(160%);
  overflow: visible;
  user-select: none;
  touch-action: pan-y;
  cursor: grab;
}

.flashcard::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(1200px 500px at 20% 10%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.flashcard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  opacity: 0.35;
  transform: translateY(12px) scale(0.975);
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.flashcard:active {
  cursor: grabbing;
}

@media (hover: hover) {
  .flashcard:hover {
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.16);
  }

  #flashcards-hero.flashcard:hover,
  #onboarding-guided-card.flashcard:hover {
    --flashcards-hover-y: -1px;
  }
}

.flashcards-subhint {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--tg-theme-hint-color, rgba(15, 23, 42, 0.55));
}

.flashcard-rate-btn {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.10);
}

.pill.primary {
  background: rgba(90, 140, 255, 0.18);
}

#flashcards-progress.pill {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(31, 48, 74, 0.2);
}

#flashcards-hero:focus-visible,
#onboarding-guided-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(46, 117, 215, 0.18), var(--glass-shadow);
}

button, .pill, .icon-btn {
  cursor: pointer;
}

@media (min-width: 900px) {
  :root {
    --shell-max-width: 920px;
    --shell-padding: 20px;
    --panel-padding: 16px;
    --surface-gap: 14px;
    --modal-max-width: 560px;
    --practice-result-max-width: 620px;
    --card-stage-min-height: min(60vh, 400px);
    --flashcard-max-width: 560px;
    --flashcard-max-height: min(60vh, 400px);
  }

  #view-home.is-active {
    grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
    align-items: start;
  }

  .home-hero-card,
  .home-stats-card {
    grid-column: 1 / -1;
  }

  .home-next-card,
  .home-attention-card {
    grid-column: 1;
  }

  .home-week-card,
  .home-recent-card {
    grid-column: 2;
  }
}

@media (max-width: 720px) {
  :root {
    --shell-padding: 13px;
    --panel-padding: 12px;
    --surface-gap: 10px;
    --modal-padding: 10px;
    --card-stage-min-height: min(48vh, 320px);
    --flashcard-max-height: min(48vh, 320px);
  }

  .topbar {
    flex-wrap: nowrap;
    align-items: center;
  }

  .badges {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }

  .badge-button {
    max-width: min(46vw, 220px);
    padding: 5px 8px;
  }

  .block-header,
  .practice-result-media.is-inline,
  .question-progress-row {
    flex-wrap: wrap;
  }

  .block-header--vocabulary {
    align-items: center;
    flex-wrap: nowrap;
  }

  .block-header-actions,
  .word-row-actions {
    width: 100%;
    max-width: 100%;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .block-header--vocabulary #manual-word-open,
  .block-header-actions {
    margin-left: auto;
  }

  .block-header--vocabulary #manual-word-open {
    width: auto;
    flex: 0 0 auto;
  }

  .word-row {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .word-row-main {
    flex: 1 1 auto;
    width: auto;
  }

  .word-row-actions {
    width: auto;
    flex: 0 0 auto;
    gap: 4px;
  }

  .word-row-action-btn {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.76rem;
  }

  .chapter-progress {
    width: 100%;
  }

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

  .mode-switch .secondary-btn {
    width: 100%;
  }

  .home-hero-card {
    padding: 16px 12px 14px;
  }

  .home-hero-count {
    font-size: clamp(2.76rem, 17vw, 4rem);
  }

  .home-hero-copy h2 {
    font-size: clamp(1.38rem, 7vw, 1.96rem);
  }

  .home-stat {
    padding: 12px 10px;
    gap: 8px;
  }

  .home-stat-copy strong {
    font-size: 1.12rem;
  }

  .home-next-content {
    flex-direction: column;
    align-items: stretch;
  }

  .home-inline-btn {
    width: 100%;
  }

  .home-inline-btn--compact {
    width: auto;
  }

  .manual-word-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .global-error {
    max-width: calc(100vw - 20px);
  }

  .onboarding-stage {
    padding: 10px;
    border-radius: 26px;
  }

  .onboarding-stage-inner {
    gap: 16px;
    padding: 22px 20px;
    border-radius: 22px;
  }

  .onboarding-choice {
    padding: 18px;
    border-radius: 20px;
  }

  .onboarding-choice-featured {
    padding-bottom: 56px;
  }

  .onboarding-choice-tag {
    min-width: 144px;
  }

  .onboarding-choice-back {
    width: min(100%, 232px);
  }
}

@media (max-width: 560px) {
  :root {
    --shell-padding: 12px;
    --panel-padding: 11px;
    --surface-gap: 10px;
    --modal-padding: 10px;
    --card-stage-min-height: min(44vh, 280px);
    --flashcard-max-height: min(44vh, 280px);
  }

  body {
    --mobile-top-offset: 10px;
    padding:
      calc(8px + var(--safe-top-inset) + var(--mobile-top-offset))
      calc(8px + var(--safe-right-inset))
      calc(8px + var(--safe-bottom-inset))
      calc(8px + var(--safe-left-inset));
  }

  .app-shell {
    border-radius: 18px;
    padding: 12px;
  }

  .topbar {
    align-items: center;
    margin-bottom: 8px;
  }

  .onboarding-stage {
    padding: 8px;
    border-radius: 24px;
  }

  .onboarding-stage-inner {
    gap: 14px;
    padding: 20px 18px;
    border-radius: 20px;
  }

  .onboarding-stage h2 {
    font-size: clamp(1.95rem, 10vw, 2.7rem);
  }

  .onboarding-stage-copy,
  .onboarding-choice-copy > span,
  .onboarding-stage-footnote {
    font-size: 0.94rem;
  }

  .onboarding-choice {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
  }

  .onboarding-choice-icon {
    width: 40px;
    height: 40px;
  }

  .onboarding-choice-icon svg {
    width: 34px;
    height: 34px;
  }

  .onboarding-choice-tag {
    min-width: 136px;
    min-height: 32px;
    font-size: 0.86rem;
  }

  .onboarding-choice-back {
    width: min(100%, 214px);
    padding: 12px 22px;
  }

  .brand h1 {
    font-size: clamp(1.26rem, 6vw, 1.56rem);
  }

  .badges {
    justify-content: flex-end;
  }

  .badge,
  .badge-button {
    font-size: 0.62rem;
    padding: 5px 8px;
  }

  .badge-button {
    max-width: min(48vw, 190px);
  }

  .tabs {
    gap: 7px;
  }

  .question-progress-row {
    width: 100%;
  }

  .tab {
    padding: 9px;
    font-size: 0.88rem;
  }

  .match-board {
    grid-template-columns: 1fr;
  }

  .manual-word-grid {
    grid-template-columns: 1fr;
  }

  .language-settings-grid {
    grid-template-columns: 1fr;
  }

  .actions.flashcards-actions-row {
    flex-direction: column;
    gap: 10px;
  }

  .flashcard-rate-btn,
  .actions.flashcards-actions-row .pill {
    width: 100%;
  }

  .modal {
    place-items: end center;
  }

  .modal-card {
    border-radius: 14px;
  }

  .practice-result-media.is-inline {
    flex-direction: column;
    align-items: flex-start;
  }

  .practice-result-image {
    width: 48px;
    height: 48px;
  }

  .cloze-slot {
    min-width: 62px;
    margin: 0 4px;
    padding: 4px 8px;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }

  .home-inline-btn--compact {
    width: auto;
  }

  .practice-hint-word {
    width: auto;
  }

  .block-header-actions .secondary-btn,
  .modal-close-btn {
    width: auto;
  }

  .home-section-header,
  .home-block-header {
    align-items: flex-start;
  }

  .home-stat {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
  }

  .home-stat-icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .home-stat-copy p {
    font-size: 0.68rem;
  }

  .home-stat-copy strong {
    font-size: 1rem;
  }

  /* Prevent iOS/WebView auto-zoom when focusing text fields. */
  .text-input,
  .text-input.cloze-inline-input {
    font-size: 16px;
  }

  .text-input.cloze-inline-input {
    max-width: min(100%, 16ch);
  }
}

@media (max-width: 360px) {
  :root {
    --shell-padding: 10px;
    --panel-padding: 10px;
    --surface-gap: 8px;
    --card-stage-min-height: min(40vh, 240px);
    --flashcard-max-height: min(40vh, 240px);
  }

  .card-text {
    font-size: clamp(22px, 8vw, 30px);
  }

  .pill {
    font-size: 0.64rem;
    padding: 4px 8px;
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn {
    padding: 9px 12px;
  }

  .home-hero-card {
    padding: 14px 10px 12px;
  }

  .home-hero-mainline {
    gap: 6px;
  }

  .home-hero-count {
    font-size: clamp(2.4rem, 18vw, 3.2rem);
  }

  .home-hero-copy h2 {
    font-size: 1.26rem;
  }

  .home-section-heading {
    gap: 8px;
  }

  .home-section-heading h3,
  .home-next-heading {
    font-size: 1rem;
  }

  .home-stat {
    padding: 9px 7px;
  }

  .home-stat-copy p,
  .home-week-progress-text,
  .home-list-meta {
    font-size: 0.72rem;
  }

  .home-list-subtitle,
  .home-next-subtitle,
  .home-week-summary {
    font-size: 0.84rem;
  }
}

@media (max-height: 740px) {
  :root {
    --shell-padding: 12px;
    --panel-padding: 10px;
    --surface-gap: 8px;
    --card-stage-min-height: min(42vh, 280px);
    --flashcard-max-height: min(42vh, 280px);
  }

  .hero-card h2,
  .question-card h3 {
    margin: 4px 0 6px;
  }

  .word-meaning,
  .word-context,
  .auth-gate-text,
  .flashcards-subhint,
  #question-prompt,
  .practice-hint-inline,
  .practice-hint-popover,
  .match-hint {
    font-size: 0.8rem;
  }

  .question-card {
    gap: 6px;
  }

  #question-term {
    font-size: 1.18rem;
  }

  .question-meta {
    margin-bottom: 5px;
  }

  .answer-area {
    gap: 6px;
    margin-top: 6px;
  }

  .onboarding-view .block {
    gap: 8px;
  }

  .onboarding-stage {
    padding: 8px;
  }

  .onboarding-stage-inner {
    gap: 14px;
    padding: 20px 18px;
  }

  .onboarding-stage h2 {
    font-size: clamp(2rem, 7vw, 2.6rem);
  }

  .onboarding-stage-copy,
  .onboarding-choice-copy > span,
  .onboarding-stage-footnote,
  .onboarding-manual-stats,
  .onboarding-guided-progress-line,
  .onboarding-guided-summary {
    font-size: 0.92rem;
  }

  .onboarding-stage-detail-inner {
    gap: 12px;
  }

  .onboarding-stage-detail h2 {
    font-size: clamp(1.5rem, 5.2vw, 1.82rem);
  }

  .onboarding-guided-panel {
    gap: 10px;
    padding: 14px;
  }

  .onboarding-guided-stage {
    min-height: min(34vh, 260px);
  }

  .onboarding-detail-input,
  .onboarding-detail-primary,
  .onboarding-detail-secondary,
  .onboarding-detail-actions .primary-btn {
    min-height: 50px;
  }

  .onboarding-choice-list {
    gap: 14px;
  }

  .onboarding-choice {
    gap: 12px;
    margin-bottom: 0;
    padding: 16px;
  }

  .onboarding-choice-featured::after {
    width: 98px;
    height: 44px;
  }

  .actions-row {
    margin-top: 8px;
    gap: 6px;
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn {
    padding: 9px 12px;
  }

  .practice-coachmark {
    padding: 10px;
  }

  .choice-btn,
  .match-token {
    padding: 8px 9px;
    font-size: 0.82rem;
  }

  .match-token-meaning {
    font-size: 0.78rem;
  }

  .match-column {
    padding: 7px;
  }

  .match-list,
  .cloze-options {
    gap: 6px;
  }

  .cloze-line {
    padding: 9px;
  }

  .cloze-inline-text {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  .practice-hint-popover {
    padding: 7px 9px;
  }
}

@media (max-height: 640px) {
  :root {
    --shell-padding: 10px;
    --panel-padding: 8px;
    --surface-gap: 6px;
    --card-stage-min-height: min(26vh, 160px);
    --flashcard-max-height: min(26vh, 160px);
  }

  body {
    padding:
      calc(6px + var(--safe-top-inset) + var(--mobile-top-offset))
      calc(6px + var(--safe-right-inset))
      calc(6px + var(--safe-bottom-inset))
      calc(6px + var(--safe-left-inset));
  }

  .onboarding-view .block {
    gap: 6px;
  }

  .onboarding-stage {
    padding: 6px;
    border-radius: 22px;
  }

  .onboarding-stage-inner {
    gap: 10px;
    padding: 14px 14px;
    border-radius: 18px;
  }

  .onboarding-stage h2 {
    font-size: clamp(1.44rem, 7.1vw, 1.82rem);
    line-height: 1.02;
  }

  .onboarding-stage-copy,
  .onboarding-choice-copy > span,
  .onboarding-stage-footnote,
  .onboarding-field-label,
  .onboarding-manual-stats,
  .onboarding-guided-progress-line,
  .onboarding-guided-summary,
  .onboarding-guided-card-helper {
    font-size: 0.72rem;
  }

  .onboarding-select,
  .onboarding-stage-primary,
  .onboarding-choice-back {
    min-height: 44px;
  }

  .onboarding-stage-detail-inner {
    gap: 7px;
  }

  .onboarding-stage-detail h2 {
    font-size: clamp(1.18rem, 5.2vw, 1.34rem);
    line-height: 1.01;
  }

  .onboarding-detail-copy {
    margin-bottom: 0;
    line-height: 1.28;
  }

  .onboarding-manual-form,
  .onboarding-manual-actions,
  .onboarding-guided-panel {
    gap: 6px;
  }

  .onboarding-detail-input,
  .onboarding-detail-primary,
  .onboarding-detail-secondary,
  .onboarding-detail-actions .primary-btn {
    min-height: 36px;
    border-radius: 16px;
  }

  .onboarding-back-link {
    font-size: 0.88rem;
  }

  .onboarding-guided-panel {
    padding: 8px;
    border-radius: 20px;
  }

  .onboarding-guided-stage {
    min-height: min(20vh, 118px);
  }

  .onboarding-choice-list {
    gap: 10px;
  }

  .onboarding-choice {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 9px;
    padding: 12px;
    border-radius: 18px;
  }

  .onboarding-choice-copy strong {
    font-size: 0.94rem;
  }

  .onboarding-choice-icon {
    width: 36px;
    height: 36px;
  }

  .onboarding-choice-icon svg {
    width: 30px;
    height: 30px;
  }

  .onboarding-choice-featured {
    padding-bottom: 42px;
  }

  .onboarding-choice-featured::after {
    right: 14px;
    bottom: 18px;
    width: 84px;
    height: 36px;
  }

  .onboarding-choice-tag {
    min-width: 116px;
    min-height: 28px;
    bottom: 8px;
    font-size: 0.74rem;
  }

  .onboarding-choice-back {
    width: min(100%, 176px);
    padding: 8px 16px;
  }

  .flashcards-screen,
  .below-card {
    gap: 6px;
  }

  #flashcards-hero,
  #onboarding-guided-card {
    padding: 12px;
  }

  #onboarding-guided-card.flashcard {
    gap: 8px;
    border-radius: 20px;
    height: min(100%, 116px);
  }

  .card-text {
    font-size: clamp(17px, 5.8vw, 22px);
  }

  .onboarding-choice span,
  .word-context,
  .flashcards-subhint {
    font-size: 0.76rem;
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn {
    padding: 8px 10px;
  }

  .question-card {
    gap: 5px;
  }

  #question-term {
    font-size: 1.05rem;
    margin-bottom: 2px;
  }

  #question-prompt,
  .practice-hint-inline,
  .practice-hint-popover,
  .match-hint {
    font-size: 0.74rem;
  }

  .question-meta {
    margin-bottom: 3px;
  }

  .question-progress-row {
    gap: 6px;
    width: 100%;
  }

  .chapter-progress {
    min-height: 26px;
    padding-bottom: 8px;
  }

  .chapter-progress::before,
  .chapter-progress__fill {
    top: 7px;
  }

  .chapter-progress__checkpoint {
    top: 7px;
    width: 10px;
    height: 10px;
  }

  .chapter-progress__checkpoint-label {
    top: 13px;
    font-size: 0.56rem;
  }

  .answer-area {
    gap: 4px;
    margin-top: 4px;
  }

  .hero-card-compact {
    min-height: 0;
  }

  .practice-mode-picker .block-header {
    margin-bottom: 6px;
  }

  .practice-coachmark {
    padding: 8px;
  }

  .choice-btn,
  .match-token {
    padding: 7px 8px;
    font-size: 0.78rem;
  }

  .match-token-meaning {
    font-size: 0.72rem;
  }

  .match-board {
    gap: 6px;
  }

  .match-column {
    padding: 6px;
  }

  .match-list {
    gap: 5px;
  }

  .match-column-title {
    margin-bottom: 5px;
  }

  .cloze-line {
    padding: 8px;
  }

  .cloze-inline-text {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .cloze-options {
    gap: 5px;
  }

  .practice-hint-popover {
    max-width: 100%;
    padding: 6px 8px;
  }

  #practice-empty-state {
    padding: 8px;
  }

  #practice-empty-state h2 {
    font-size: 1.02rem;
    margin: 4px 0;
  }

  #practice-empty-state p,
  #practice-empty-feedback {
    font-size: 0.76rem;
  }
}

.onboarding-view {
  display: grid;
  gap: 0;
  margin-bottom: 0;
  flex: 1 1 auto;
  min-height: 0;
  align-content: stretch;
}

.onboarding-choice {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.onboarding-view .block {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
}

.onboarding-stage {
  width: 100%;
  min-height: 100%;
  padding: 12px;
  border-radius: 30px;
  border: 1px solid rgba(170, 189, 214, 0.7);
  background: linear-gradient(145deg, rgba(202, 215, 231, 0.92), rgba(163, 188, 217, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 20px 38px rgba(84, 117, 156, 0.22);
}

.onboarding-stage-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(18px, 4vw, 30px);
  border-radius: 26px;
  border: 1px solid rgba(190, 204, 224, 0.9);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.48), transparent 42%),
    linear-gradient(145deg, rgba(244, 246, 251, 0.98), rgba(219, 227, 239, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 18px 36px rgba(119, 144, 178, 0.14);
}

.onboarding-stage h2 {
  margin: 0;
  font-size: clamp(1.84rem, 5vw, 2.72rem);
  line-height: 1.06;
  letter-spacing: -0.04em;
  color: #183265;
}

.onboarding-stage-copy {
  margin: 0;
  max-width: 24ch;
  color: #4d618d;
  font-size: clamp(0.94rem, 2.2vw, 1.08rem);
  line-height: 1.45;
}

.onboarding-field-stack {
  display: grid;
  gap: 8px;
}

.onboarding-field-label {
  letter-spacing: 0.15em;
  color: #5e7196;
}

.onboarding-select {
  min-height: 54px;
  padding: 0 48px 0 18px;
  border-radius: 18px;
  border-color: rgba(170, 190, 219, 0.82);
  background:
    linear-gradient(180deg, rgba(251, 252, 255, 0.96), rgba(237, 241, 248, 0.98)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18' fill='none'%3E%3Cpath d='M5 7.25L9 11.25L13 7.25' stroke='%23182c59' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right 16px center;
  appearance: none;
  -webkit-appearance: none;
  color: #1d1d1f;
  font-size: 1rem;
}

.onboarding-stage-footnote {
  margin: 0;
  color: #55698f;
  font-size: 0.92rem;
  line-height: 1.4;
}

.onboarding-stage-primary {
  margin-top: auto;
  min-height: 58px;
  border-radius: 19px;
  font-size: 1.02rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    0 14px 24px rgba(44, 107, 203, 0.32);
}

.onboarding-stage-choice .onboarding-stage-inner {
  gap: 18px;
}

.onboarding-choice-list {
  display: grid;
  gap: 14px;
}

.onboarding-choice {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin: 0;
  padding: 20px 22px;
  border-radius: 22px;
  border: 1px solid rgba(176, 195, 222, 0.82);
  background:
    radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.38), transparent 34%),
    linear-gradient(155deg, rgba(251, 252, 255, 0.96), rgba(230, 236, 245, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 14px 28px rgba(114, 141, 180, 0.16);
}

.onboarding-choice-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding-right: 12px;
}

.onboarding-choice-copy strong {
  font-size: clamp(1.04rem, 2.9vw, 1.28rem);
  line-height: 1.1;
  color: #1a3163;
}

.onboarding-choice-copy > span {
  color: #394f7d;
  font-size: clamp(0.84rem, 2.1vw, 0.98rem);
  line-height: 1.45;
}

.onboarding-choice-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #6a95d8;
}

.onboarding-choice-icon svg {
  width: 40px;
  height: 40px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.onboarding-choice-featured {
  padding-bottom: 60px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 18px 30px rgba(88, 125, 177, 0.2);
}

.onboarding-choice-featured::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 22px;
  width: 116px;
  height: 52px;
  border-right: 3px dashed rgba(101, 145, 222, 0.78);
  border-bottom: 3px dashed rgba(101, 145, 222, 0.78);
  border-radius: 0 0 60px 0;
  opacity: 0.8;
  pointer-events: none;
}

.onboarding-choice-tag {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 156px;
  min-height: 34px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #71a5f4 0%, #3f7fdd 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    0 8px 18px rgba(63, 127, 221, 0.28);
  color: rgba(255, 255, 255, 0.98);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
}

.onboarding-choice-back {
  align-self: center;
  width: min(100%, 238px);
  margin-top: auto;
  border-radius: 18px;
  padding: 14px 28px;
  border: 1px solid rgba(173, 192, 220, 0.9);
  background: linear-gradient(180deg, rgba(239, 244, 251, 0.94), rgba(220, 230, 243, 0.92));
  color: #1a3163;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 10px 22px rgba(122, 147, 183, 0.16);
}

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

.onboarding-stage-detail {
  min-height: 100%;
}

.onboarding-stage-detail .onboarding-stage-inner {
  align-items: stretch;
}

.onboarding-stage-detail h2 {
  max-width: none;
  font-size: clamp(1.68rem, 4.4vw, 2.12rem);
}

.onboarding-stage-detail-inner {
  gap: 14px;
}

.onboarding-detail-topbar {
  display: flex;
  align-items: center;
}

.onboarding-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #355a95;
  font-size: 1.12rem;
  font-weight: 500;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.02em;
  box-shadow: none;
}

.onboarding-back-link:hover,
.onboarding-back-link:active {
  transform: none;
}

.onboarding-detail-copy {
  max-width: none;
  margin-bottom: 2px;
  line-height: 1.34;
}

.onboarding-manual-form {
  display: grid;
  gap: 10px;
}

.onboarding-detail-input {
  min-height: 54px;
  border-radius: 18px;
  padding: 0 18px;
  border-color: rgba(170, 190, 219, 0.82);
  background: linear-gradient(180deg, rgba(251, 252, 255, 0.96), rgba(237, 241, 248, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 18px rgba(122, 147, 183, 0.08);
  font-size: 1rem;
}

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

.onboarding-detail-primary,
.onboarding-detail-secondary,
.onboarding-detail-actions .primary-btn {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
}

.onboarding-manual-stats,
.onboarding-guided-summary {
  margin: 0;
  min-height: 0;
  color: #50658e;
  font-size: 0.98rem;
  line-height: 1.35;
}

.onboarding-detail-actions {
  margin-top: 0;
}

.onboarding-guided-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 28px;
  border: 1px solid rgba(199, 212, 232, 0.9);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.48), transparent 42%),
    linear-gradient(145deg, rgba(244, 246, 251, 0.82), rgba(220, 228, 239, 0.74));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 14px 28px rgba(119, 144, 178, 0.12);
}

.onboarding-guided-progress-line {
  margin: 0;
  color: #5b6f95;
  font-size: 0.94rem;
  line-height: 1.25;
}

.onboarding-guided-stage {
  position: relative;
  min-height: min(38vh, 300px);
  isolation: isolate;
}

.onboarding-guided-stage::before,
.onboarding-guided-stage::after {
  content: "";
  position: absolute;
  top: 28px;
  bottom: 28px;
  width: 24%;
  border-radius: 24px;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  z-index: 0;
}

.onboarding-guided-stage::before {
  left: 6px;
  transform: translateX(8px);
  background: linear-gradient(180deg, rgba(246, 189, 194, 0.12), rgba(224, 104, 118, 0.28));
}

.onboarding-guided-stage::after {
  right: 6px;
  transform: translateX(-8px);
  background: linear-gradient(180deg, rgba(181, 236, 204, 0.14), rgba(67, 172, 111, 0.28));
}

.onboarding-guided-stage[data-swipe="left"]::before {
  opacity: 1;
  transform: translateX(0);
}

.onboarding-guided-stage[data-swipe="right"]::after {
  opacity: 1;
  transform: translateX(0);
}

#onboarding-guided-card.flashcard {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  border-radius: 28px;
  text-align: center;
}

.onboarding-guided-card-helper {
  margin: 0;
  color: #7382a4;
  font-size: 0.84rem;
  line-height: 1.3;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: opacity 140ms ease;
}

#onboarding-guided-card.is-flipped .onboarding-guided-card-helper {
  opacity: 0;
}

#onboarding-guided-card .card-text {
  display: block;
}

#view-practice.is-active,
#practice-tasks-mode {
  min-height: 0;
  align-content: start;
}

@media (max-height: 740px) {
  .topbar {
    margin-bottom: 10px;
  }

  .tabs {
    margin-bottom: 10px;
  }

  .home-hero-card {
    padding-top: 15px;
    padding-bottom: 12px;
  }

  .home-hero-mainline {
    margin-block: 6px 8px;
  }

  .home-hero-cta {
    min-height: 48px;
    margin-top: 12px;
  }

  .home-hero-estimate {
    margin-top: 9px;
    font-size: 0.82rem;
  }

  .home-next-card,
  .home-week-card {
    gap: 10px;
  }

  .home-list-row {
    padding-block: 12px;
  }

  .onboarding-stage-detail h2 {
    font-size: clamp(1.5rem, 5.2vw, 1.82rem);
  }

  .onboarding-stage-detail-inner {
    gap: 12px;
  }

  .onboarding-detail-copy,
  .onboarding-manual-stats,
  .onboarding-guided-progress-line,
  .onboarding-guided-summary {
    font-size: 0.84rem;
  }

  .onboarding-detail-input,
  .onboarding-detail-primary,
  .onboarding-detail-secondary,
  .onboarding-detail-actions .primary-btn {
    min-height: 48px;
  }

  .onboarding-guided-panel {
    gap: 8px;
    padding: 12px;
  }

  .onboarding-guided-stage {
    min-height: min(28vh, 220px);
  }
}

@media (max-height: 640px) {
  .brand h1 {
    font-size: clamp(1.14rem, 5vw, 1.32rem);
  }

  .tab {
    padding: 8px;
    font-size: 0.84rem;
  }

  .home-hero-count {
    font-size: clamp(2.5rem, 14vw, 3.3rem);
  }

  .home-hero-copy h2 {
    font-size: clamp(1.22rem, 5vw, 1.48rem);
  }

  .home-stats-card {
    min-height: 76px;
  }

  .home-stat {
    padding: 8px 7px;
    gap: 5px;
  }

  .home-stat-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .home-stat-copy p {
    font-size: 0.64rem;
  }

  .home-stat-copy strong {
    font-size: 0.92rem;
  }

  .home-list-row {
    padding-block: 10px;
  }

  .onboarding-stage-detail h2 {
    font-size: clamp(1.18rem, 5.2vw, 1.34rem);
    line-height: 1.01;
  }

  .onboarding-stage-detail-inner {
    gap: 7px;
    padding: 12px;
  }

  .onboarding-detail-copy,
  .onboarding-manual-stats,
  .onboarding-guided-progress-line,
  .onboarding-guided-summary,
  .onboarding-guided-card-helper {
    font-size: 0.68rem;
    line-height: 1.22;
  }

  .onboarding-back-link {
    font-size: 0.88rem;
  }

  .onboarding-field-stack,
  .onboarding-manual-form,
  .onboarding-manual-actions,
  .onboarding-guided-panel {
    gap: 6px;
  }

  .onboarding-detail-input,
  .onboarding-detail-primary,
  .onboarding-detail-secondary,
  .onboarding-detail-actions .primary-btn {
    min-height: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: 14px;
  }

  .onboarding-guided-panel {
    padding: 8px;
    border-radius: 20px;
  }

  .onboarding-guided-stage {
    min-height: 132px;
  }

  .onboarding-guided-stage::before,
  .onboarding-guided-stage::after {
    top: 18px;
    bottom: 18px;
    border-radius: 18px;
  }

  #onboarding-guided-card {
    padding: 10px;
  }

  #onboarding-guided-card.flashcard {
    gap: 8px;
    height: 108px;
    border-radius: 18px;
  }

  #onboarding-guided-card .card-text {
    font-size: clamp(16px, 5.4vw, 22px);
  }

  .onboarding-detail-actions .primary-btn {
    min-height: 40px;
    height: 40px;
  }
}
