/* ===== Wordsier — "Ink & Highlighter" =====
   Ngôn ngữ thị giác: từ điển in + nét bút dạ quang.
   Serif cho headword/tiêu đề, sans cho UI, mono cho phiên âm. */
:root {
  --bg-a: #faf7f9;
  --bg-b: #faf7f9;
  --paper: #faf7f9;
  --card: #ffffff;
  --ink: #251a22;
  --muted: #7b6d77;
  --line: #e8dde4;
  --brand: #b32377;
  --brand-deep: #8c1a5e;
  --brand-soft: #f7e3ee;
  --brand-wash: #f7e3ee;
  /* Wordsier logo gradient. Kept apart from --brand because the mark has its
     own fixed identity colours rather than the app's accent. */
  --logo-a: #ff5f9e;
  --logo-b: #38a9f5;
  --marker: #f9d65c;
  --marker-wash: rgba(249, 214, 92, 0.45);
  --danger: #b3392c;
  --good: #2c7a4b;
  --shadow: 0 10px 30px rgba(83, 32, 62, 0.09);
  --line-strong: #d3bfcb;
  --focus-ring: #b32377;
  --surface-soft: #ffffff;
  --surface-tint: #f7e3ee;
  --surface-highlight: rgba(179, 35, 119, 0.06);
  --surface-highlight-strong: rgba(179, 35, 119, 0.12);
  --hero-gradient: var(--card);
  --brand-gradient: var(--brand);
  --game-front-gradient: var(--card);
  --game-front-preview-gradient: var(--paper);
  --game-back-gradient: linear-gradient(180deg, #ffffff, #fbf1f7);
  --game-card-gradient: var(--card);
  --game-prompt-gradient: linear-gradient(160deg, #fdf4f9, #f7e3ee);
  --accent-contrast: #8c1a5e;
  --on-brand: #ffffff;
  --star-added: #c9930f;
  --font-display: "Charter", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-sans: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

/* Desktop dark mode theo OS preference (mobile view có theme tối riêng bên dưới) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-a: #1b1419;
    --bg-b: #1b1419;
    --paper: #1b1419;
    --card: #262029;
    --ink: #f2eaef;
    --muted: #a8969f;
    --line: #3d323a;
    --brand: #ef77b8;
    --brand-deep: #f79cca;
    --brand-soft: rgba(239, 119, 184, 0.14);
    --brand-wash: rgba(239, 119, 184, 0.14);
    /* The brand pack's dark-background variant: the light-mode stops go muddy
       and lose contrast against a near-black bar. */
    --logo-a: #ff8fbc;
    --logo-b: #63c2ff;
    --marker: #caa53a;
    --marker-wash: rgba(202, 165, 58, 0.28);
    --danger: #ee8577;
    --good: #6fce97;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --line-strong: #55464f;
    --focus-ring: #ef77b8;
    --surface-soft: #262029;
    --surface-tint: rgba(239, 119, 184, 0.14);
    --surface-highlight: rgba(239, 119, 184, 0.08);
    --surface-highlight-strong: rgba(239, 119, 184, 0.16);
    --game-back-gradient: linear-gradient(180deg, #262029, #2b2230);
    --game-prompt-gradient: linear-gradient(160deg, #2b2230, #262029);
    --accent-contrast: #f79cca;
    --on-brand: #1b1419;
    --star-added: #edc84a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  background: linear-gradient(160deg, var(--bg-a), var(--bg-b));
  min-height: 100vh;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: none;
}

.page-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 1.6rem;
  height: 1.6rem;
  flex: none;
}

.brand-stop-a {
  stop-color: var(--logo-a);
}

.brand-stop-b {
  stop-color: var(--logo-b);
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* The W picks up the same gradient as the mark. -webkit-background-clip is
   still required alongside the standard property for Safari. */
.brand-initial {
  background: linear-gradient(135deg, var(--logo-a), var(--logo-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.topbar-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 2px;
}

.topbar-link:hover {
  color: var(--ink);
  background: linear-gradient(transparent 78%, var(--brand-wash) 78%);
}

.mobile-nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mobile-nav-toggle:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-wash);
}

.mobile-nav-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
  color: var(--ink);
}

.mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 18, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 36;
}

.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: min(280px, 86vw);
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 30px rgba(64, 42, 56, 0.15);
  padding: 14px;
  transform: translateX(102%);
  transition: transform 0.23s ease;
  z-index: 37;
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.mobile-nav-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mobile-nav-close svg {
  width: 18px;
  height: 18px;
  display: block;
}

.mobile-nav-close:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-wash);
}

.mobile-nav-logout {
  width: 100%;
}

.mobile-nav-links {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.mobile-nav-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}

body.mobile-nav-open {
  overflow: hidden;
}

body.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.mobile-nav-open .mobile-nav-drawer {
  transform: translateX(0);
}

.identity-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.avatar-icon {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--brand);
  background: var(--brand-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-icon svg {
  width: 18px;
  height: 18px;
}

.avatar-photo {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--card);
}

.identity {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.content {
  display: grid;
  gap: 18px;
}

.hero {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 8px 0;
  font-size: clamp(1.8rem, 2.8vw, 2.4rem);
  font-family: var(--font-display);
  text-wrap: balance;
}

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

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--brand);
}

.hero .eyebrow {
  color: var(--brand);
}

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

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

.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

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

.topic-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.panel-head-wrap {
  align-items: flex-start;
}

.panel-head-no-title {
  justify-content: flex-end;
}

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

.mobile-create-trigger {
  display: none;
}

.search-form {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.search-form .button {
  white-space: nowrap;
}

.topic-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  color: var(--ink);
  background: var(--card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 18px rgba(64, 42, 56, 0.05);
}

.topic-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow);
}

.topic-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topic-card-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topic-folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-wash);
  color: var(--brand);
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.topic-folder-icon svg {
  width: 26px;
  height: 26px;
}

.topic-copy {
  min-width: 0;
}

/* Mũi tên tròn tô hồng đặc — khớp phong cách thẻ của /m */
.topic-arrow {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  background: var(--brand);
  color: var(--on-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 10px 20px rgba(64, 42, 56, 0.18);
  transition: transform 0.15s ease, background 0.15s ease;
}

.topic-card:hover .topic-arrow {
  background: var(--brand-deep);
  transform: translateX(2px);
}

.topic-arrow svg {
  width: 18px;
  height: 18px;
}

.topic-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.14rem;
  font-weight: 700;
  line-height: 1.22;
}

.topic-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--font-mono);
}

/* Nút sửa/xoá ẩn khi nghỉ, trượt hiện khi hover/focus (desktop dùng chuột) */
.topic-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.18s ease, opacity 0.18s ease, margin-top 0.18s ease;
}

.topic-card:hover .topic-actions,
.topic-card:focus-within .topic-actions {
  max-height: 44px;
  margin-top: 12px;
  opacity: 1;
}

.topic-card-clickable {
  cursor: pointer;
}

.topic-card-clickable:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.topic-sort-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topic-sort-form select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: var(--card);
}

.topic-modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  width: min(420px, 90vw);
  background: var(--card);
  color: var(--ink);
}

.topic-modal::backdrop {
  background: rgba(20, 12, 18, 0.45);
}

.topic-modal h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.topic-modal p {
  margin: 0 0 12px;
  color: var(--muted);
}

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

.modal-actions {
  display: flex;
  gap: 8px;
}

.topic-pager {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.pager-link {
  text-decoration: none;
  color: var(--brand);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.pager-link:hover {
  text-decoration: underline;
}

.pager-disabled {
  color: var(--muted);
  opacity: 0.5;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.pager-current {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

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

.list li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.list a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.list span {
  color: var(--muted);
  font-size: 0.93rem;
}

.word-list {
  gap: 0;
}

.word-list li.word-item {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 4px;
}

.word-list li.word-item:last-child {
  border-bottom: 0;
}

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

/* Entry từ điển: headword serif + /IPA/ mono + pos in nghiêng */
.word-headword {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.ipa {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--brand);
}

.pos-tag {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--muted);
}

.word-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.word-copy strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.word-audio-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-highlight);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.word-audio-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface-highlight-strong);
}

.word-audio-button:disabled,
.audio-quiz-listen-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.word-audio-button:disabled:hover,
.audio-quiz-listen-button:disabled:hover {
  transform: none;
  border-color: var(--line);
  background: var(--surface-highlight);
}

.word-audio-button.is-playing {
  color: var(--on-brand);
  background: var(--brand);
  border-color: var(--brand);
}

.word-audio-button svg {
  width: 20px;
  height: 20px;
}

.desktop-word-audio-button {
  flex: 0 0 auto;
}

.word-actions form {
  margin: 0;
}

.word-review-trigger {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  min-width: 0;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.word-review-trigger strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.12rem;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.word-review-trigger span {
  color: var(--muted);
  font-size: 0.93rem;
}

.word-review-trigger .word-mean::before {
  content: "— ";
  color: var(--muted);
}

.word-review-modal {
  max-height: min(86vh, 720px);
  overflow: auto;
  border-radius: 22px;
  padding: 20px;
}

.word-review-modal h4 {
  margin: 0 0 6px;
  font-size: 1.18rem;
}

.word-review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.word-review-head h4 {
  margin: 0;
}

.word-review-audio-button {
  flex: 0 0 auto;
}

.word-review-block {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.word-review-block strong {
  color: var(--brand);
  font-size: 0.88rem;
}

.word-review-block p {
  margin: 0;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}

.word-review-list {
  list-style: disc;
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  display: grid;
  gap: 4px;
}

.readonly-input {
  background: var(--surface-highlight);
  color: var(--muted);
}

.word-create-screen h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
}

.word-create-form {
  gap: 12px;
}

.word-advanced-toggle {
  justify-self: start;
}

.word-advanced-fields {
  display: grid;
  gap: 12px;
}

.word-advanced-fields[hidden] {
  display: none;
}

.word-type-trigger {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  padding: 10px 12px;
  font-size: 1.02rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.word-type-trigger.has-value {
  color: var(--ink);
}

.word-type-dialog {
  width: min(520px, 92vw);
}

.word-type-options {
  display: grid;
  gap: 8px;
  max-height: min(56vh, 420px);
  overflow: auto;
  padding-right: 2px;
}

.word-type-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.word-type-option:hover {
  border-color: var(--line-strong);
  background: var(--brand-wash);
}

.word-suggest-list {
  margin: -4px 0 0;
  padding: 0;
  list-style: none;
  display: none;
  gap: 8px;
}

.word-suggest-list.has-items {
  display: grid;
}

.word-suggest-item {
  margin: 0;
}

.word-suggest-button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.word-suggest-button:hover {
  border-color: var(--line-strong);
  background: var(--brand-wash);
}

.inline-form,
.form-grid {
  display: grid;
  gap: 12px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--card);
}

textarea {
  resize: vertical;
}

label span {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.button {
  display: inline-block;
  text-align: center;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  padding: 11px 16px;
  font-family: var(--font-sans);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.button-small {
  padding: 8px 10px;
  font-size: 0.86rem;
}

.button-danger {
  background: var(--danger);
  color: var(--on-brand);
}

.button-danger:hover {
  background: var(--danger);
  filter: brightness(0.9);
}

.oauth-button {
  text-decoration: none;
  margin-top: 8px;
}

.manual-login {
  margin-top: 16px;
}

.manual-login summary {
  cursor: pointer;
  color: var(--muted);
  margin-bottom: 10px;
}

.button-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}

.button-ghost:hover {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
}

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

.chip {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.88rem;
}

.message {
  margin: 10px 0 0;
  color: var(--muted);
}

.message-error {
  color: var(--danger);
}

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

.game-grid {
  display: grid;
  gap: 16px;
}

.practice-form {
  display: grid;
  gap: 18px;
}

.practice-topic-panel {
  display: grid;
  gap: 14px;
}

.practice-selection-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.practice-topic-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.practice-topic-option {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.practice-topic-option:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.practice-topic-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.practice-topic-copy {
  display: block;
  padding: 16px 18px;
}

.practice-topic-copy strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

/* Starter-topic library on the dashboard. The cards reuse .topic-card, but
   they are not links — the action is the save button, so no hover lift and no
   arrow affordance. */
.library-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* The action shares the row with the title, in the slot an ordinary topic
   card gives its arrow. Neither it nor the "saved" label may shrink or wrap;
   the title takes whatever is left and wraps instead. */
.library-save-form {
  flex: 0 0 auto;
}

.library-save-form .button {
  white-space: nowrap;
}

.library-saved {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Below this the title and the button genuinely cannot share a line, so give
   the button its own full-width row — deliberate, rather than a stray blob
   pushed to the right. */
@media (max-width: 400px) {
  .library-card .topic-card-head {
    flex-wrap: wrap;
  }

  .library-save-form {
    flex: 1 1 100%;
  }

  .library-save-form .button {
    width: 100%;
  }
}

/* Marks a shared starter topic. Deliberately quiet: it labels the source of
   the words, it is not a call to action. */
.practice-topic-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
}

.practice-topic-option.is-selected,
.practice-topic-option:has(input:checked) {
  border-color: var(--brand);
  background: linear-gradient(180deg, rgba(179, 35, 119, 0.1), rgba(179, 35, 119, 0.03));
}

.practice-actions-row {
  display: flex;
  justify-content: flex-end;
}

.practice-start-button {
  min-width: 220px;
}

.practice-game-button {
  width: 100%;
  text-align: left;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.practice-game-button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.practice-picker-modal {
  width: min(560px, 92vw);
}

.practice-picker-copy {
  max-width: 420px;
  line-height: 1.45;
}

.practice-picker-modal .modal-actions {
  margin-top: 4px;
}

.practice-topic-grid-modal {
  max-height: min(46vh, 360px);
  overflow: auto;
  padding-right: 4px;
}

.mobile-game-grid {
  gap: 14px;
}

.game-card-link {
  text-decoration: none;
  color: inherit;
}

.game-card {
  display: grid;
  gap: 14px;
}

.game-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.practice-game-icon {
  color: var(--brand);
}

.page-flashcard .page-shell,
.page-quiz .page-shell,
.page-audio-quiz .page-shell {
  max-width: none;
  min-height: 100vh;
  padding: 0;
}

.page-flashcard .content,
.page-quiz .content,
.page-audio-quiz .content {
  min-height: 100vh;
}

.flashcard-game {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  width: 100%;
}

.flashcard-stage {
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.flashcard-close {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 10px 24px rgba(17, 27, 42, 0.12);
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.flashcard-close svg {
  width: 20px;
  height: 20px;
}

.flashcard-stack {
  width: 100%;
  height: 380px;
  position: relative;
  flex: 0 0 auto;
}

.flashcard-controls {
  width: 100%;
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
}

.flashcard-controls[hidden] {
  display: none;
}

.flashcard-reveal-button {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
}

.flashcard-exit-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.flashcard-empty {
  margin: 0;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
  line-height: 1.45;
}

.flashcard-card {
  width: 100%;
  max-width: 460px;
  height: 100%;
  position: relative;
  perspective: 1800px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  transition: transform 0.22s ease;
}

.flashcard-card.is-dragging {
  transition: none;
}

.flashcard-card.is-exiting,
.flashcard-card.is-exiting-left,
.flashcard-card.is-exiting-right {
  transition: transform 0.18s cubic-bezier(0.4, 0, 1, 1);
}

.flashcard-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.56s cubic-bezier(0.22, 1, 0.36, 1);
}

.flashcard-state-card {
  position: absolute;
  inset: 0;
  cursor: default;
}

.flashcard-slot.is-current {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.flashcard-slot.is-next {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transform-origin: center top;
  opacity: 0.62;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.flashcard-slot.is-promoting {
  transition: transform 0.22s ease, opacity 0.22s ease;
}

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

.flashcard-face {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  padding: 24px;
  backface-visibility: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  align-content: flex-start;
  gap: 14px;
  overflow: hidden;
}

.flashcard-audio-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
}

.flashcard-state-face {
  position: static;
  width: 100%;
  height: 100%;
  justify-content: center;
  text-align: center;
}

.flashcard-front {
  background: var(--game-front-gradient);
}

.flashcard-slot.is-next .flashcard-front,
.flashcard-slot.is-promoting .flashcard-front {
  background: var(--game-front-preview-gradient);
  border-color: var(--line);
  box-shadow: 0 16px 28px rgba(64, 42, 56, 0.08);
}

.flashcard-slot.is-next .flashcard-hint,
.flashcard-slot.is-promoting .flashcard-hint {
  opacity: 0;
}

.flashcard-back {
  background: var(--game-back-gradient);
  transform: rotateY(180deg);
}

.flashcard-face-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

.flashcard-word {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1.04;
}

.flashcard-slot.is-next .flashcard-word,
.flashcard-slot.is-promoting .flashcard-word {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  line-height: 1.1;
  color: var(--ink);
  text-align: center;
}

.flashcard-hint {
  margin: auto 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.flashcard-meaning {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.15;
}

.flashcard-state-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2rem);
  line-height: 1.12;
}

.flashcard-state-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.flashcard-pos {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.flashcard-example-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-highlight);
  border: 1px solid var(--line);
}

.flashcard-example-block strong {
  color: var(--brand);
  font-size: 0.9rem;
}

.flashcard-example-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--ink);
}

.quiz-game {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  width: 100%;
}

.quiz-stage {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
}

.quiz-card {
  border-radius: 26px;
  border: 1px solid var(--line);
  background: var(--game-card-gradient);
  box-shadow: 0 22px 48px rgba(64, 42, 56, 0.14);
  padding: 24px;
  display: grid;
  gap: 18px;
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.quiz-head-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.quiz-eyebrow {
  letter-spacing: 0.14em;
  font-size: 0.7rem;
}

.quiz-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.34rem, 2.4vw, 1.78rem);
  line-height: 1.08;
}

.quiz-progress {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-highlight);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
}

.quiz-body {
  display: grid;
  gap: 14px;
}

.quiz-prompt-block {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 20px 22px;
  border-radius: 22px;
  background: var(--game-prompt-gradient);
  border: 1px solid var(--line);
}

.quiz-word {
  margin: 0;
  max-width: calc(100% - 56px);
  font-family: var(--font-display);
  font-size: clamp(1.72rem, 4vw, 2.42rem);
  line-height: 1;
}

.quiz-copy {
  margin: 0;
  max-width: 32ch;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.42;
}

.quiz-pos {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.94rem;
}

.quiz-audio-button {
  position: absolute;
  top: 18px;
  right: 18px;
}

.quiz-example-block {
  margin-top: -2px;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 14px 16px;
  text-align: left;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.quiz-option:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface-highlight);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.is-correct {
  border-color: var(--good);
  background: rgba(62, 157, 104, 0.14);
  color: var(--good);
}

.quiz-option.is-wrong {
  border-color: var(--danger);
  background: rgba(209, 99, 99, 0.12);
  color: var(--danger);
}

.quiz-feedback {
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-highlight);
  font-weight: 700;
  font-size: 0.96rem;
  line-height: 1.45;
}

.quiz-feedback.is-correct {
  border-color: rgba(62, 157, 104, 0.34);
  background: rgba(62, 157, 104, 0.14);
  color: var(--good);
}

.quiz-feedback.is-wrong {
  border-color: rgba(209, 99, 99, 0.36);
  background: rgba(209, 99, 99, 0.12);
  color: var(--danger);
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
}

.quiz-next-button {
  min-width: 180px;
}

.audio-quiz-prompt {
  gap: 14px;
}

.audio-quiz-copy {
  max-width: 34ch;
}

.audio-quiz-listen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: flex-start;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 16px;
  border-color: rgba(179, 35, 119, 0.24);
  background: var(--brand-gradient);
  box-shadow: 0 16px 28px rgba(64, 42, 56, 0.28);
}

.audio-quiz-listen-button svg {
  width: 20px;
  height: 20px;
}

.audio-quiz-listen-button.is-playing {
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.2);
}

.audio-quiz-answer-word {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.14rem, 2.1vw, 1.34rem);
  line-height: 1.12;
  color: var(--ink);
}

.login-panel {
  max-width: 760px;
  margin: 10vh auto 0;
}

.login-copy h1 {
  margin: 6px 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.7vw, 2.2rem);
}

.login-copy p {
  color: var(--muted);
  margin-top: 0;
}

.link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 900px) {
  .topic-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    background: var(--paper);
  }

  .page-shell {
    padding: 10px 10px 90px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 -2px 12px;
    padding: 10px 8px;
    background: color-mix(in srgb, var(--paper) 90%, transparent);
    border: 1px solid var(--line);
    border-radius: 14px;
    backdrop-filter: blur(8px);
  }

  .brand-mark {
    font-size: 1.15rem;
  }

  .brand-logo {
    width: 1.35rem;
    height: 1.35rem;
  }

  .top-actions {
    margin-left: auto;
  }

  .desktop-logout-form {
    display: none;
  }

  .topbar-nav {
    display: none;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  .identity {
    max-width: 118px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.84rem;
  }

  .logout-btn {
    display: none;
  }

  .content {
    gap: 12px;
  }

  .hero {
    border-radius: 14px;
    padding: 18px;
  }

  .hero h1 {
    font-size: 1.48rem;
  }

  .panel {
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 8px 20px rgba(64, 42, 56, 0.1);
  }

  .search-panel {
    display: none;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .search-form .button {
    min-width: 88px;
  }

  .create-topic-panel {
    display: none;
  }

  .panel-head-wrap {
    gap: 10px;
  }

  .panel-head-no-title {
    justify-content: flex-start;
  }

  .mobile-nav-backdrop,
  .mobile-nav-drawer {
    display: block;
  }

  .topic-head-actions {
    width: 100%;
    display: grid;
    gap: 10px;
  }

  .mobile-create-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 14px;
    bottom: 18px;
    z-index: 35;
    width: auto;
    min-width: 120px;
    border-radius: 999px;
    box-shadow: 0 16px 30px rgba(64, 42, 56, 0.35);
  }

  .topic-sort-form {
    display: none;
  }

  .topic-card {
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 8px 18px rgba(64, 42, 56, 0.1);
  }

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

  .topic-pager {
    justify-content: space-between;
    gap: 10px;
  }

  .topic-modal {
    width: 100vw;
    max-width: none;
    margin: 0;
    border-radius: 18px 18px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    padding: 16px;
    position: fixed;
    bottom: 0;
  }

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

  .button,
  input,
  textarea,
  select,
  .topic-sort-form select {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 8px 7px;
  }

  .top-actions {
    gap: 8px;
  }

  .identity {
    max-width: 96px;
  }

  .avatar-photo,
  .avatar-icon {
    width: 28px;
    height: 28px;
  }

  .search-form .button {
    min-width: 76px;
    padding: 10px 10px;
  }

  .topic-sort-form {
    grid-template-columns: 1fr auto;
    gap: 6px;
  }

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

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

  .mobile-create-trigger {
    right: 12px;
    bottom: 14px;
    min-width: 112px;
    padding: 10px 12px;
  }
}

body.view-mobile {
  --bg-a: #1b1419;
  --bg-b: #1b1419;
  --paper: #262029;
  --card: #262029;
  --ink: #f2eaef;
  --muted: #a8969f;
  --line: #3d323a;
  --brand: #ef77b8;
  --brand-deep: #f79cca;
  --brand-soft: rgba(239, 119, 184, 0.16);
  --brand-wash: rgba(239, 119, 184, 0.16);
  --marker: #caa53a;
  --marker-wash: rgba(202, 165, 58, 0.28);
  --danger: #ee8577;
  --good: #6fce97;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.38);
  --line-strong: #55464f;
  --focus-ring: #ef77b8;
  --surface-soft: #262029;
  --surface-tint: rgba(239, 119, 184, 0.14);
  --surface-highlight: rgba(239, 119, 184, 0.1);
  --surface-highlight-strong: rgba(239, 119, 184, 0.18);
  --hero-gradient: var(--card);
  --brand-gradient: var(--brand);
  --game-front-gradient: linear-gradient(165deg, #2b2230, #262029);
  --game-front-preview-gradient: linear-gradient(180deg, #241d26, #1f191f);
  --game-back-gradient: linear-gradient(180deg, #262029, #2b2230);
  --game-card-gradient: linear-gradient(180deg, #262029, #221c24);
  --game-prompt-gradient: linear-gradient(165deg, #2b2230, #262029);
  --accent-contrast: #f79cca;
  --on-brand: #1b1419;
  --star-added: #edc84a;
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: #1b1419;
}

body.view-mobile,
body.view-mobile button,
body.view-mobile input,
body.view-mobile textarea,
body.view-mobile select {
  font-family: var(--font-sans);
}

body.view-mobile h1,
body.view-mobile h2,
body.view-mobile h3,
body.view-mobile h4,
body.view-mobile .brand-title,
body.view-mobile .mobile-topic-name,
body.view-mobile .mobile-topic-chip,
body.view-mobile .mobile-word-title,
body.view-mobile .flashcard-word,
body.view-mobile .flashcard-meaning,
body.view-mobile .flashcard-state-title,
body.view-mobile .quiz-title,
body.view-mobile .quiz-word,
body.view-mobile .audio-quiz-answer-word {
  font-family: var(--font-display);
  letter-spacing: 0;
}

body.view-mobile .brand-title,
body.view-mobile .mobile-topic-name,
body.view-mobile .mobile-topic-chip,
body.view-mobile .mobile-word-title,
body.view-mobile .flashcard-word,
body.view-mobile .flashcard-meaning,
body.view-mobile .flashcard-state-title,
body.view-mobile .quiz-title,
body.view-mobile .quiz-word,
body.view-mobile .audio-quiz-answer-word,
body.view-mobile .topic-modal h4,
body.view-mobile .word-review-modal h4 {
  font-weight: 700;
}

body.view-mobile .eyebrow,
body.view-mobile .flashcard-face-eyebrow,
body.view-mobile .quiz-eyebrow {
  letter-spacing: 0.16em;
  font-size: 0.66rem;
}

body.view-mobile .bg-layer {
  display: block;
  background: radial-gradient(circle at 50% 0%, rgba(239, 119, 184, 0.06), transparent 40%);
}

body.view-mobile .page-shell {
  max-width: 430px;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(22px + env(safe-area-inset-bottom));
}

body.view-mobile .topbar {
  position: static;
  margin: 0 0 14px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  backdrop-filter: none;
  box-shadow: none;
}

body.view-mobile .brand {
  align-items: baseline;
  color: var(--ink);
}

body.view-mobile .brand-mark {
  font-size: clamp(1.2rem, 5vw, 1.35rem);
}

body.view-mobile .top-actions {
  margin-left: auto;
}

body.view-mobile .identity-wrap,
body.view-mobile .desktop-logout-form {
  display: none;
}

body.view-mobile .mobile-nav-toggle {
  display: inline-flex;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(239, 119, 184, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
}

body.view-mobile .mobile-nav-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--ink);
}

body.view-mobile .mobile-nav-backdrop,
body.view-mobile .mobile-nav-drawer {
  display: block;
}

body.view-mobile .mobile-nav-backdrop {
  background: rgba(10, 7, 9, 0.72);
}

body.view-mobile .mobile-nav-drawer {
  background: linear-gradient(180deg, rgba(95, 18, 62, 0.98), rgba(54, 7, 33, 0.98));
  border-left-color: rgba(239, 119, 184, 0.24);
  box-shadow: -14px 0 34px rgba(0, 0, 0, 0.4);
}

body.view-mobile .mobile-nav-header strong {
  color: var(--ink);
}

body.view-mobile .mobile-nav-close {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(239, 119, 184, 0.28);
  color: var(--ink);
}

body.view-mobile.page-topic-detail .topbar,
body.view-mobile.page-topic-detail .mobile-nav-backdrop,
body.view-mobile.page-topic-detail .mobile-nav-drawer {
  display: none;
}

body.view-mobile.page-topic-detail .page-shell {
  padding-top: 8px;
}

body.view-mobile .content {
  gap: 14px;
}

body.view-mobile .hero {
  background: var(--hero-gradient);
  box-shadow: 0 20px 38px rgba(43, 36, 45, 0.42);
}

body.view-mobile .hero h1 {
  font-size: clamp(1.56rem, 7.2vw, 2rem);
  line-height: 1.08;
}

body.view-mobile .hero .eyebrow {
  color: var(--brand);
}

body.view-mobile .hero p {
  color: var(--muted);
}

body.view-mobile .panel {
  background: var(--card);
  border-color: var(--line);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.32);
}

body.view-mobile .button {
  background: var(--brand-gradient);
  box-shadow: 0 12px 22px rgba(64, 42, 56, 0.34);
}

body.view-mobile .button-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(239, 119, 184, 0.3);
  color: var(--ink);
  box-shadow: none;
}

body.view-mobile .button-danger {
  background: var(--danger);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.25);
}

body.view-mobile input,
body.view-mobile textarea,
body.view-mobile select {
  background: #2e2630;
  border-color: rgba(239, 119, 184, 0.28);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.view-mobile input::placeholder,
body.view-mobile textarea::placeholder {
  color: #a8969f;
}

body.view-mobile .topic-modal {
  background: var(--card);
  box-shadow: 0 -16px 34px rgba(0, 0, 0, 0.42);
}

body.view-mobile .topic-modal::backdrop {
  background: rgba(10, 7, 9, 0.76);
}

body.view-mobile .word-review-modal {
  width: min(420px, calc(100vw - 24px));
  max-width: none;
  max-height: min(78vh, 720px);
  margin: 0;
  padding: 20px 18px 18px;
  border: 1px solid rgba(239, 119, 184, 0.28);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(43, 36, 45, 0.98), rgba(30, 24, 31, 0.98));
  box-shadow:
    0 26px 54px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(239, 119, 184, 0.08);
  position: fixed;
  top: 50%;
  left: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

body.view-mobile .word-review-modal h4 {
  color: var(--ink);
  font-size: 1.22rem;
  line-height: 1.18;
}

body.view-mobile .word-review-block {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(239, 119, 184, 0.22);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.view-mobile .word-review-block strong {
  color: #f79cca;
}

body.view-mobile .word-review-block p,
body.view-mobile .word-review-list {
  color: var(--ink);
}

body.view-mobile .word-audio-button {
  border-color: rgba(239, 119, 184, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: #f79cca;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

body.view-mobile .word-audio-button.is-playing {
  background: var(--brand-gradient);
  border-color: rgba(239, 119, 184, 0.56);
  color: var(--on-brand);
}

body.view-mobile .word-audio-button:disabled,
body.view-mobile .audio-quiz-listen-button:disabled {
  opacity: 0.36;
  border-color: rgba(239, 119, 184, 0.24);
  background: rgba(255, 255, 255, 0.04);
  color: #84737d;
  box-shadow: none;
}

body.view-mobile .word-review-modal .modal-actions {
  margin-top: 14px;
}

body.view-mobile .word-type-trigger,
body.view-mobile .word-type-option,
body.view-mobile .word-suggest-button {
  background: rgba(36, 30, 38, 0.98);
  border-color: rgba(239, 119, 184, 0.28);
  color: var(--ink);
}

body.view-mobile .word-type-trigger {
  color: #a8969f;
}

body.view-mobile .word-type-trigger.has-value {
  color: var(--ink);
}

body.view-mobile .word-type-option:hover,
body.view-mobile .word-suggest-button:hover {
  border-color: rgba(239, 119, 184, 0.56);
  background: rgba(239, 119, 184, 0.18);
}

body.view-mobile .link,
body.view-mobile .pager-link {
  color: #f79cca;
}

body.view-mobile .pager-disabled {
  color: #84737d;
}

body.view-mobile .message,
body.view-mobile .empty,
body.view-mobile .pager-current {
  color: var(--muted);
}

body.view-mobile .message-error {
  color: #ee8577;
}

body.view-mobile .topbar-link {
  display: none;
}

body.view-mobile .mobile-nav-link {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(239, 119, 184, 0.28);
  color: var(--ink);
}

body.view-mobile .practice-topic-option {
  background: rgba(43, 36, 45, 0.94);
  border-color: rgba(239, 119, 184, 0.22);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.22);
}

body.view-mobile .practice-topic-option.is-selected,
body.view-mobile .practice-topic-option:has(input:checked) {
  border-color: rgba(239, 119, 184, 0.56);
  background: linear-gradient(180deg, rgba(239, 119, 184, 0.34), rgba(43, 36, 45, 0.96));
}

body.view-mobile .practice-topic-copy strong,
body.view-mobile .flashcard-close,
body.view-mobile .quiz-title,
body.view-mobile .flashcard-state-title {
  color: var(--ink);
}

body.view-mobile .flashcard-close {
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  border-color: rgba(239, 119, 184, 0.28);
  background: rgba(30, 24, 31, 0.92);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
}

body.view-mobile .flashcard-game {
  align-items: stretch;
  justify-content: flex-start;
  padding: calc(74px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom));
}

body.view-mobile .flashcard-stage {
  max-width: none;
  gap: 18px;
}

body.view-mobile .flashcard-stack {
  height: clamp(400px, 52dvh, 520px);
}

body.view-mobile .flashcard-reveal-button {
  min-height: 56px;
}

body.view-mobile .flashcard-reveal-button {
  background: var(--brand-gradient);
  box-shadow: 0 16px 28px rgba(64, 42, 56, 0.36);
}

body.view-mobile .flashcard-hint,
body.view-mobile .flashcard-pos,
body.view-mobile .flashcard-empty,
body.view-mobile .flashcard-state-copy,
body.view-mobile .quiz-copy,
body.view-mobile .quiz-progress,
body.view-mobile .practice-selection-hint {
  color: var(--muted);
}

body.view-mobile .flashcard-hint,
body.view-mobile .flashcard-state-copy,
body.view-mobile .quiz-copy,
body.view-mobile .quiz-feedback,
body.view-mobile .practice-picker-copy,
body.view-mobile .mobile-topic-meta,
body.view-mobile .mobile-word-mean {
  line-height: 1.5;
}

body.view-mobile .flashcard-front {
  background: var(--game-front-gradient);
  border-color: rgba(239, 119, 184, 0.24);
  box-shadow: 0 22px 40px rgba(43, 36, 45, 0.4);
}

body.view-mobile .flashcard-front .flashcard-face-eyebrow,
body.view-mobile .flashcard-front .flashcard-hint,
body.view-mobile .flashcard-front .flashcard-word {
  color: var(--ink);
}

body.view-mobile .flashcard-slot.is-next .flashcard-front,
body.view-mobile .flashcard-slot.is-promoting .flashcard-front {
  background: var(--game-front-preview-gradient);
  border-color: rgba(239, 119, 184, 0.24);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.24);
}

body.view-mobile .flashcard-slot.is-next .flashcard-face-eyebrow,
body.view-mobile .flashcard-slot.is-promoting .flashcard-face-eyebrow,
body.view-mobile .flashcard-slot.is-next .flashcard-word,
body.view-mobile .flashcard-slot.is-promoting .flashcard-word {
  color: #f79cca;
}

body.view-mobile .flashcard-back {
  background: var(--game-back-gradient);
  border-color: rgba(239, 119, 184, 0.24);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.34);
}

body.view-mobile .flashcard-back .flashcard-face-eyebrow {
  color: #f79cca;
}

body.view-mobile .flashcard-state-face {
  background: var(--game-back-gradient);
  border-color: rgba(239, 119, 184, 0.24);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.34);
}

body.view-mobile .flashcard-audio-button {
  border-color: rgba(239, 119, 184, 0.24);
  background: rgba(30, 24, 31, 0.22);
  color: var(--ink);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.28);
}

body.view-mobile .flashcard-audio-button.is-playing {
  background: rgba(30, 24, 31, 0.92);
  border-color: rgba(255, 255, 255, 0.28);
  color: #f79cca;
}

body.view-mobile .flashcard-back .flashcard-meaning,
body.view-mobile .flashcard-back .flashcard-example-list,
body.view-mobile .flashcard-back .flashcard-example-block strong {
  color: var(--ink);
}

body.view-mobile .flashcard-example-block {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(239, 119, 184, 0.24);
}

body.view-mobile .quiz-card {
  background: var(--game-card-gradient);
  border-color: rgba(239, 119, 184, 0.24);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.34);
  border-radius: 24px;
  padding: 18px 16px 16px;
  gap: 16px;
}

body.view-mobile .quiz-game {
  align-items: stretch;
  justify-content: flex-start;
  padding: calc(74px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom));
}

body.view-mobile .quiz-stage {
  max-width: none;
}

body.view-mobile .quiz-close {
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  padding: 8px 12px;
  gap: 6px;
  border-radius: 16px;
  font-size: 0.92rem;
}

body.view-mobile .quiz-close svg {
  width: 18px;
  height: 18px;
}

body.view-mobile .quiz-head {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

body.view-mobile .quiz-head-copy {
  gap: 4px;
}

body.view-mobile .quiz-title {
  font-size: clamp(1.42rem, 7vw, 1.82rem);
  line-height: 1.08;
}

body.view-mobile .quiz-progress {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(239, 119, 184, 0.24);
  align-self: flex-start;
  padding: 7px 11px;
  font-size: 0.84rem;
}

body.view-mobile .quiz-prompt-block {
  background: var(--game-prompt-gradient);
  border-color: rgba(239, 119, 184, 0.24);
  box-shadow: 0 22px 40px rgba(43, 36, 45, 0.4);
  border-radius: 20px;
  padding: 18px 18px 16px;
  gap: 8px;
}

body.view-mobile .quiz-word,
body.view-mobile .quiz-pos,
body.view-mobile .quiz-copy {
  color: var(--ink);
}

body.view-mobile .quiz-word {
  max-width: calc(100% - 48px);
  font-size: clamp(1.82rem, 10vw, 2.26rem);
  line-height: 1.04;
}

body.view-mobile .quiz-pos {
  font-size: 0.92rem;
}

body.view-mobile .quiz-copy {
  max-width: 20ch;
  font-size: 0.98rem;
  line-height: 1.38;
  color: var(--muted);
}

body.view-mobile .quiz-audio-button {
  border-color: rgba(239, 119, 184, 0.24);
  background: rgba(30, 24, 31, 0.22);
  color: var(--ink);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.28);
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
}

body.view-mobile .quiz-audio-button.is-playing {
  background: rgba(30, 24, 31, 0.92);
  border-color: rgba(255, 255, 255, 0.28);
  color: #f79cca;
}

body.view-mobile .quiz-option {
  background: rgba(36, 30, 38, 0.98);
  border-color: rgba(239, 119, 184, 0.28);
  color: var(--ink);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.24);
  border-radius: 15px;
  padding: 13px 14px;
  font-size: 0.98rem;
  line-height: 1.32;
  min-height: 58px;
}

body.view-mobile .quiz-option:hover:not(:disabled) {
  border-color: rgba(239, 119, 184, 0.56);
  background: rgba(239, 119, 184, 0.18);
}

body.view-mobile .quiz-options {
  gap: 8px;
}

body.view-mobile .quiz-option.is-correct {
  border-color: rgba(102, 218, 162, 0.42);
  background: rgba(35, 102, 74, 0.9);
  color: #e8fff4;
}

body.view-mobile .quiz-option.is-wrong {
  border-color: rgba(255, 126, 160, 0.42);
  background: rgba(84, 34, 61, 0.92);
  color: #ffe6ee;
}

body.view-mobile .quiz-feedback {
  border-color: rgba(239, 119, 184, 0.24);
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.42;
}

body.view-mobile .quiz-feedback.is-correct {
  border-color: rgba(102, 218, 162, 0.42);
  background: rgba(35, 102, 74, 0.9);
  color: #e8fff4;
}

body.view-mobile .quiz-feedback.is-wrong {
  border-color: rgba(255, 126, 160, 0.42);
  background: rgba(84, 34, 61, 0.92);
  color: #ffe6ee;
}

body.view-mobile .quiz-example-block {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(239, 119, 184, 0.24);
  padding: 10px 14px;
  border-radius: 16px;
  gap: 6px;
}

body.view-mobile .quiz-example-block .flashcard-example-list,
body.view-mobile .quiz-example-block strong {
  color: var(--ink);
}

body.view-mobile .quiz-example-block strong {
  font-size: 0.86rem;
}

body.view-mobile .quiz-example-block .flashcard-example-list {
  padding-left: 16px;
  gap: 4px;
  font-size: 0.88rem;
  line-height: 1.35;
}

body.view-mobile .quiz-body {
  gap: 12px;
}

body.view-mobile .quiz-actions {
  justify-content: stretch;
}

body.view-mobile .quiz-next-button {
  width: 100%;
  min-width: 0;
  border-radius: 14px;
  font-size: 0.98rem;
}

body.view-mobile .audio-quiz-prompt {
  gap: 10px;
}

body.view-mobile .audio-quiz-listen-button {
  width: 100%;
  justify-content: center;
  border-radius: 14px;
  padding: 12px 14px;
}

body.view-mobile .audio-quiz-listen-button.is-playing {
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.25);
}

body.view-mobile .audio-quiz-answer-word {
  color: var(--ink);
  font-size: 1.08rem;
}

.mobile-note {
  margin: 0;
  padding: 0 2px;
}

.mobile-topic-list {
  display: grid;
  gap: 12px;
}

.mobile-topic-detail-page {
  display: grid;
  gap: 16px;
  padding: 2px 0 90px;
}

.mobile-topic-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-topic-back {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f2eaef;
  text-decoration: none;
  border: 1px solid rgba(239, 119, 184, 0.24);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.16);
}

.mobile-topic-back svg {
  width: 22px;
  height: 22px;
}

.mobile-topic-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(239, 119, 184, 0.28);
  background: rgba(43, 36, 45, 0.96);
  color: #f2eaef;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
}

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

.mobile-word-loading {
  text-align: center;
}

.mobile-word-sentinel {
  height: 1px;
}

.mobile-word-card {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(239, 119, 184, 0.24);
  background: rgba(43, 36, 45, 0.96);
  padding: 14px 62px 14px 14px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
}

.mobile-word-pressable {
  cursor: pointer;
  touch-action: pan-y;
}

.mobile-word-card.is-holding {
  border-color: rgba(239, 119, 184, 0.54);
}

.mobile-word-card.is-delete-ready {
  border-color: rgba(255, 144, 196, 0.44);
  background: rgba(74, 34, 48, 0.92);
}

.mobile-word-icon {
  width: 32px;
  height: 32px;
  color: #f79cca;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.mobile-word-icon svg {
  width: 100%;
  height: 100%;
}

.mobile-word-body {
  min-width: 0;
}

.mobile-word-audio-button {
  position: absolute;
  top: 12px;
  right: 12px;
}

.mobile-word-title {
  display: block;
  color: #f2eaef;
  font-size: 1.1rem;
  line-height: 1.24;
}

.mobile-word-mean {
  margin: 6px 0 0;
  color: #a8969f;
  font-size: 0.98rem;
  line-height: 1.42;
}

.mobile-word-fab {
  position: fixed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 18px;
  background: var(--brand-gradient);
  color: var(--on-brand);
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 18px 28px rgba(64, 42, 56, 0.42);
  cursor: pointer;
  z-index: 32;
}

.mobile-topic-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(239, 119, 184, 0.24);
  background: rgba(43, 36, 45, 0.94);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
}

.mobile-topic-pressable {
  cursor: pointer;
  touch-action: pan-y;
}

.topic-delete-form {
  display: none;
}

.mobile-topic-card.is-holding {
  border-color: rgba(239, 119, 184, 0.54);
}

.mobile-topic-card.is-delete-ready {
  border-color: rgba(255, 144, 196, 0.44);
  background: rgba(74, 34, 48, 0.92);
}

.mobile-topic-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mobile-topic-copy {
  min-width: 0;
}

.mobile-folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(239, 119, 184, 0.18);
  color: #f79cca;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.mobile-folder-icon svg {
  width: 28px;
  height: 28px;
}

.mobile-topic-name {
  display: block;
  color: var(--ink);
  font-size: clamp(1.02rem, 4.4vw, 1.34rem);
  font-weight: 800;
  line-height: 1.22;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-topic-meta {
  display: block;
  margin-top: 4px;
  color: #a8969f;
  font-size: clamp(0.8rem, 3.2vw, 0.98rem);
  line-height: 1.4;
}

.mobile-topic-arrow {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--brand-gradient);
  color: var(--on-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 12px 22px rgba(64, 42, 56, 0.32);
}

.mobile-topic-arrow svg {
  width: 18px;
  height: 18px;
}

.mobile-pager {
  margin-top: 4px;
}

.mobile-topic-fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--brand-gradient);
  color: var(--on-brand);
  font-size: 1.9rem;
  line-height: 1;
  box-shadow: 0 18px 28px rgba(64, 42, 56, 0.42);
}

@media (max-width: 430px) {
  .mobile-topic-card {
    padding: 12px;
    border-width: 1.5px;
  }

  .mobile-folder-icon {
    width: 38px;
    height: 38px;
  }

  .mobile-folder-icon svg {
    width: 24px;
    height: 24px;
  }

  .mobile-topic-name {
    font-size: clamp(0.96rem, 5vw, 1.18rem);
  }

  .mobile-topic-meta {
    font-size: clamp(0.74rem, 3.6vw, 0.9rem);
  }

  .mobile-topic-arrow {
    width: 38px;
    height: 38px;
  }

  .mobile-topic-arrow svg {
    width: 16px;
    height: 16px;
  }

  .mobile-topic-chip {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.94rem;
    line-height: 1.2;
  }

  .mobile-word-card {
    padding: 12px;
    border-radius: 14px;
  }

  .mobile-word-icon {
    width: 28px;
    height: 28px;
  }

  .mobile-word-title {
    font-size: 1.02rem;
  }

  .mobile-word-mean {
    font-size: 0.92rem;
  }

  .mobile-word-fab {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    font-size: 1.8rem;
  }

  .mobile-topic-fab {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 1.65rem;
  }

  .flashcard-stack {
    height: clamp(360px, 48dvh, 440px);
  }

  .flashcard-card,
  .flashcard-card-inner {
    height: 100%;
  }

  .flashcard-face {
    padding: 18px;
    border-radius: 22px;
  }

  .flashcard-word {
    font-size: clamp(1.7rem, 8vw, 2.2rem);
  }

  .flashcard-meaning {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
  }
}

/* ===== Home page — dictionary search ===== */
.home-search {
  max-width: 640px;
  margin: 0 auto;
  padding-top: clamp(24px, 8vh, 80px);
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.home-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.1;
  text-wrap: balance;
}

.home-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.home-search-box {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 14px 18px;
  margin-top: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}

.home-search-box svg {
  flex: 0 0 auto;
  color: var(--muted);
}

.home-search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--ink);
  width: 100%;
  padding: 0;
  border-radius: 0;
}

.home-search-box input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.home-search-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.home-search-status.is-error {
  color: var(--danger);
}

.home-results {
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.home-results.has-items {
  display: block;
}

.home-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

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

.home-result-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.home-result-word {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.home-result-mean {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.home-result-mean::before {
  content: "— ";
}

.home-result-audio {
  flex: 0 0 auto;
}

.home-quick-links {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 480px) {
  .home-search {
    padding-top: 18px;
  }

  .home-quick-links {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Home — add-to-topic (star + popup) */
.home-result-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-result-star:hover {
  color: var(--brand);
}

.home-result-star svg {
  width: 19px;
  height: 19px;
}

.home-result-star.is-added {
  color: var(--star-added);
  border-color: var(--star-added);
  background: transparent;
}

.home-result-star.is-added svg path {
  fill: currentColor;
}

.home-result-star.is-added:hover {
  color: var(--star-added);
  border-color: var(--star-added);
  background: var(--surface-highlight);
}

.home-add-modal {
  width: min(440px, 92vw);
}

.home-add-word-preview {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
}

.home-add-empty {
  margin: 0 0 12px;
  color: var(--muted);
}

.home-topic-options {
  display: grid;
  gap: 8px;
  max-height: min(48vh, 340px);
  overflow: auto;
  padding-right: 2px;
  margin-bottom: 12px;
}

.home-topic-option {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  padding: 11px 13px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.home-topic-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-highlight);
}

.home-topic-option.is-selected {
  border-color: var(--brand);
  background: var(--brand-wash);
}

.home-topic-option-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-topic-option-meta {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
}

/* ===== "Ôn tập hôm nay" widget (dashboard) ===== */
.review-widget {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: grid;
  gap: 16px;
}

.review-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.review-streak {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--brand-wash);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.review-widget-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.review-stats {
  display: flex;
  gap: 28px;
}

.review-stat {
  display: flex;
  flex-direction: column;
}

.review-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.review-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}

.review-cta {
  text-decoration: none;
  white-space: nowrap;
}

.review-done {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 560px) {
  .review-widget-body {
    align-items: stretch;
  }

  .review-cta {
    width: 100%;
    text-align: center;
  }
}

/* ===== Topic progress (mới / đang học / đã thuộc) ===== */
.topic-progress {
  display: flex;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  margin-top: 2px;
}

.tp-seg {
  display: block;
  min-width: 3px;
  flex-shrink: 0;
}

.tp-mastered { background: var(--good); }
.tp-learning { background: var(--brand); }
.tp-new { background: color-mix(in srgb, var(--muted) 40%, transparent); }

.topic-progress-legend {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.topic-progress-legend .tp-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
  margin-left: 8px;
}

.topic-progress-legend .tp-dot:first-child {
  margin-left: 0;
}

/* Mobile variant */
.mobile-topic-progress {
  height: 5px;
  margin-top: 8px;
}

.mobile-topic-progress-legend {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}

/* ===== Language switch (VI | EN) ===== */
.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
  flex: 0 0 auto;
}

.lang-opt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 10px;
  line-height: 1;
}

.lang-opt.is-active {
  background: var(--brand);
  color: var(--on-brand);
}

.lang-opt:not(.is-active):hover {
  color: var(--brand);
}

body.view-mobile .lang-switch {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}

/* ---- search result rows link to the word detail page ---- */

.home-result-body {
  flex: 1 1 auto;
  color: inherit;
  text-decoration: none;
}

.home-result-body:hover .home-result-word {
  color: var(--brand);
}

/* ---- word detail page ---- */

.word-detail {
  display: grid;
  gap: 18px;
  max-width: 720px;
}

.word-detail-back {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  justify-self: start;
}

.word-detail-back:hover {
  color: var(--brand);
}

.word-detail-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.word-detail-word {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
}

.word-detail-ipa {
  font-size: 0.95rem;
}

.word-detail-audio {
  align-self: center;
  margin-left: auto;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
  justify-self: start;
}

.mode-option {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 8px 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.mode-option.is-active {
  background: var(--brand);
  color: var(--on-brand);
}

.mode-option:not(.is-active):hover {
  color: var(--brand);
}

.word-detail-panel {
  min-height: 40px;
}

.sense-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
}

.sense-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

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

.sense-row .pos-tag {
  flex: 0 0 96px;
}

.sense-meaning {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
}

.sense-add {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
}

.sense-add svg {
  width: 17px;
  height: 17px;
}

.sense-add.is-added {
  color: var(--on-brand);
  background: var(--brand);
  border-color: var(--brand);
}

.word-detail-empty,
.word-detail-hint,
.word-detail-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.word-detail-status.is-error {
  color: var(--danger, #c0392b);
}

/* ---- model-generated markdown ---- */

.markdown-body {
  color: var(--ink);
  line-height: 1.65;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body > *:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-family: var(--font-display);
  margin: 20px 0 8px;
}

.markdown-body p {
  margin: 0 0 12px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-highlight);
  border-radius: 4px;
  padding: 1px 5px;
}

.markdown-body pre {
  overflow-x: auto;
  background: var(--surface-highlight);
  border-radius: 10px;
  padding: 12px 14px;
}

.markdown-body blockquote {
  margin: 0 0 12px;
  padding-left: 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.quick-translation {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--ink);
}

/* ===== Landing ===== */

.landing-intro {
  text-align: center;
  padding: 32px 0 8px;
}

.landing-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--ink);
}

.landing-sub {
  margin: 0 auto 22px;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.landing-cta {
  display: inline-flex;
}

.landing-section {
  margin-top: 48px;
}

.landing-heading {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 18px;
  color: var(--ink);
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.landing-card,
.landing-game {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.landing-card h3,
.landing-game h3 {
  margin: 12px 0 6px;
  font-size: 1.05rem;
  color: var(--ink);
}

.landing-card p,
.landing-game p,
.landing-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.landing-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-wash);
  color: var(--brand);
}

.landing-card-icon svg {
  width: 22px;
  height: 22px;
}

.landing-games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.landing-game-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-wash);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.landing-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.landing-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
}

.landing-step h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  color: var(--ink);
}

.landing-step-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

/* ===== Locked pages ===== */

/* Blurred rather than hidden: the visitor should see the shape of what they
   would be signing in for, without any of it being readable or clickable. */
.content-locked {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

.locked-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  margin: 0 0 20px;
  color: var(--ink);
}

.locked-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.locked-card {
  height: 112px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}

.locked-card-tall {
  height: 190px;
}

.locked-rows {
  display: grid;
  gap: 12px;
}

.locked-row {
  height: 58px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}

.force-login-modal {
  max-width: 420px;
  text-align: center;
}

.force-login-body {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.force-login-cta {
  width: 100%;
  justify-content: center;
}

.force-login-alt {
  display: inline-block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ===== Guest menu ===== */

/* Signed in, the hamburger is a narrow-screen affordance. Signed out it is the
   only navigation there is, so it stays visible at every width.
 *
 * The drawer and backdrop need the same treatment: they are display:none until
 * the 768px breakpoint, so showing the button alone leaves it opening nothing
 * on a desktop. */
.nav-toggle-guest {
  display: inline-flex;
}

.mobile-nav-backdrop.nav-guest,
.mobile-nav-drawer.nav-guest {
  display: block;
}

.mobile-nav-signin {
  width: 100%;
  justify-content: center;
  margin-top: auto;
}

/* ===== Dashboard blocks on a phone =====
 *
 * The dashboard is used mostly on a phone, where three things read badly:
 * the panel heading was squeezed onto two lines, the two review figures sat
 * at ragged offsets that made them hard to compare, and the cards still
 * carried desktop-sized padding and affordances. */
@media (max-width: 768px) {
  /* .topic-head-actions is width:100% at this width, but by now its create
   * button is position:fixed and its sort form is display:none — so it was an
   * invisible full-width box shoving "All topics" onto two lines. Giving the
   * heading a row of its own takes the pressure off without hiding anything. */
  .panel-head-wrap {
    flex-wrap: wrap;
  }

  .panel-head-wrap > h2 {
    flex: 1 1 100%;
  }

  .review-widget {
    padding: 16px;
    gap: 12px;
  }

  /* Stack rather than wrap: the figures get a row, the call to action gets a
   * row, and neither depends on how wide the labels happen to be.
   *
   * The explicit 1fr track matters. The base rule sets justify-content:
   * space-between for the flex layout, and that carries into grid, where it
   * shrinks an implicit auto track down to its content — which left the CTA
   * only as wide as the two figures above it. */
  .review-widget-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Equal columns, so the two numbers line up with each other instead of
   * drifting apart with the width of the label above them. The rule is on the
   * second stat only, so a single figure never gets a stray divider. */
  .review-stats {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }

  .review-stat + .review-stat {
    padding-left: 16px;
    border-left: 1px solid var(--line);
  }

  .review-num {
    font-size: 1.7rem;
  }

  .review-label {
    margin-top: 4px;
    line-height: 1.35;
  }

  .review-cta {
    width: 100%;
    text-align: center;
  }

  /* The arrow points the way, it is not the subject of the card. At 40px with
   * a drop shadow it was reading as the primary action. */
  .topic-arrow {
    width: 32px;
    height: 32px;
    box-shadow: none;
  }

  .topic-arrow svg {
    width: 16px;
  }

  /* Three counts on one line at 0.7rem ran edge to edge on a narrow phone.
   * A tighter gap lets them wrap in pairs instead of overflowing. */
  .topic-progress-legend {
    gap: 4px 8px;
    font-size: 0.68rem;
  }
}
