/* "Từ vựng của bạn" (your-vocab.js): mobile YourVocabScreen's style (AppTokens, Mali, the 28 px
   flip card, tonal UK/US pills, pill buttons), laid out for the web: page head with the view
   switch, search and "Thêm từ vựng"; the cards as a focused panel beside a sticky card index;
   the list as a table. Phones keep the app's single column. */
.yv-page {
  --yv-link: var(--md-hero);
  --yv-on-primary-container: var(--md-on-primary-container);
  --yv-surface-container: var(--md-surface-container);
  --yv-error: var(--md-error);
  --yv-error-container: var(--md-error-container);
  --yv-shadow: var(--md-card-shadow);
  gap: 24px;
}
.yv-page h2,
.yv-page p {
  margin: 0;
}
.yv-page ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.yv-page .mi,
.yv-dialog .mi {
  width: 20px;
  height: 20px;
  flex: none;
}
.yv-file {
  display: none;
}

/* ---------- page head: intro + count, view switch, search, add ---------- */
.yv-head {
  align-items: center;
}
.yv-intro {
  display: grid;
  gap: 4px;
}
.yv-count {
  color: var(--md-on-surface-variant);
  font-size: 14px;
}
.yv-count strong {
  color: var(--md-on-surface);
  font: 700 15px/20px var(--font-app-bold);
}
.yv-actions {
  flex: none;
  flex-wrap: nowrap;
  gap: 10px;
}
.yv-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-width: 220px;
  padding: 3px;
  border-radius: 14px;
  background: #e7eeec;
}
.yv-seg-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--md-on-surface-variant);
  font: 600 14px/18px var(--font-app);
}
.yv-seg-btn:hover {
  color: var(--md-on-surface);
}
.yv-seg-btn[aria-pressed="true"] {
  background: var(--md-surface);
  color: var(--md-primary);
  box-shadow: 0 1px 3px #0e242026;
}
.yv-search {
  flex: 0 1 260px;
  margin: 0;
  font-weight: 400;
}
.yv-search .mi {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--md-outline);
  pointer-events: none;
}
.yv-page .yv-search input {
  height: 50px;
  min-height: 50px;
  padding-left: 42px;
  border-color: var(--md-outline-variant);
  border-radius: 14px;
  font-family: var(--font-app);
}
.yv-add {
  flex: none;
  white-space: nowrap;
  min-height: 50px;
  padding: 0 22px 0 18px;
  border-radius: 999px;
  background: var(--md-primary);
  font: 700 15px/20px var(--font-app-bold);
}
.yv-add .mi {
  width: 22px;
  height: 22px;
}

/* ---------- notes ---------- */
.yv-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border-radius: 14px;
  background: var(--md-streak-container);
  color: var(--md-on-streak-container);
  font-size: 14px;
  line-height: 20px;
}
.yv-notice span {
  flex: 1;
}
.yv-notice .button {
  flex: none;
  color: var(--md-warning);
}
.yv-local {
  max-width: 560px;
  margin: 0 auto;
  color: var(--md-on-surface-variant);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
#yv-pending:empty {
  display: none;
}

/* ---------- empty / no results ---------- */
.yv-empty {
  padding: 32px 24px 40px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 24px;
  background: var(--md-surface);
  box-shadow: var(--yv-shadow);
}
.yv-empty .story-empty-mam {
  width: 170px;
}
.yv-page .yv-empty p {
  max-width: 440px;
  color: var(--md-on-surface-variant);
}

/* ---------- Thẻ: the focused study panel + the card index ---------- */
.yv-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}
.yv-study {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 760px;
  justify-self: center;
  padding: 22px 32px 24px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 26px;
  background: var(--md-surface);
  box-shadow: var(--yv-shadow);
}
.yv-study-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.yv-position {
  color: var(--md-on-surface-variant);
  font: 600 14px/20px var(--font-app);
}
.yv-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--md-outline-variant);
  border-radius: 999px;
  background: var(--md-surface);
  color: var(--yv-link);
  font: 600 14px/18px var(--font-app);
}
.yv-pill:hover {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}
.yv-pill.is-filled {
  border-color: var(--md-primary);
  background: var(--md-primary);
  color: #fff;
}
.yv-pill.is-filled:hover {
  background: var(--md-hero);
}
.yv-pill .mi {
  width: 18px;
  height: 18px;
}

/* CardFront / CardBack on one 3-D card (EasyFlipView, 400 ms). */
.yv-deck {
  perspective: 1600px;
  touch-action: pan-y;
}
.yv-card {
  /* Tall enough for a full back, short enough that the arrows stay in view at 768 px. */
  height: clamp(320px, calc(100vh - 420px), 440px);
  cursor: pointer;
}
.yv-card-inner {
  position: relative;
  height: 100%;
  transform-style: preserve-3d;
}
.yv-card.is-flipped .yv-card-inner {
  transform: rotateY(180deg);
}
.yv-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 28px;
  overflow-y: auto;
  border: 1px solid var(--md-outline-variant);
  border-radius: 28px;
  background: var(--md-surface);
  box-shadow: 0 1px 3px #0e24201a;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* Centred when it fits, scrollable from the top when it does not. */
.yv-face > :first-child {
  margin-top: auto;
}
.yv-face > :last-child {
  margin-bottom: auto;
}
.yv-face.is-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #f6fbfa, var(--md-surface) 60%);
}
.yv-type {
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--yv-surface-container);
  color: var(--md-on-surface-variant);
  font: 700 12px/16px var(--font-app-bold);
}
.yv-word {
  max-width: 100%;
  color: var(--md-on-surface);
  font: 700 36px/44px var(--font-app-bold);
  overflow-wrap: anywhere;
}
.yv-word.is-hidden {
  color: var(--md-outline);
  letter-spacing: 0.04em;
  white-space: pre-wrap;
}
.yv-phon {
  color: var(--md-on-surface-variant);
  font-size: 17px;
  line-height: 24px;
}
/* Mali has no glyph for IPA stress marks (ˈ ˌ), so phonetics use the system face. */
.yv-phon,
.yv-row-phon {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.yv-clue {
  max-width: 100%;
  color: var(--md-on-surface);
  font: 600 22px/28px var(--font-app);
  overflow-wrap: anywhere;
}
.yv-accents {
  display: flex;
  gap: 8px;
}
.yv-accent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--md-primary-container);
  color: var(--yv-on-primary-container);
  font: 700 14px/18px var(--font-app-bold);
}
.yv-accent:hover {
  background: #c8e8e1;
}
.yv-accent .mi {
  width: 18px;
  height: 18px;
}
.yv-check {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}
.yv-answer {
  width: 100%;
  min-height: 50px;
  padding: 10px 20px;
  border: 1.5px solid var(--md-outline-variant);
  border-radius: 999px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font: 400 16px/22px var(--font-app);
  text-align: center;
}
.yv-answer[aria-invalid="true"] {
  border-color: var(--yv-error);
}
.yv-wrong {
  color: var(--yv-error);
  font-size: 13px;
  line-height: 18px;
}
.yv-wrong:empty {
  display: none;
}
.yv-check-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.yv-forgot {
  min-height: 44px;
  color: var(--md-on-surface-variant);
  font-family: var(--font-app);
}
.yv-meaning {
  max-width: 100%;
  color: var(--yv-on-primary-container);
  font: 700 26px/32px var(--font-app-bold);
  overflow-wrap: anywhere;
}
.yv-divider {
  flex: none;
  width: 48px;
  height: 2px;
  border-radius: 2px;
  background: var(--md-divider);
}
.yv-example {
  max-width: 560px;
  color: var(--md-on-surface);
  font-size: 15px;
  font-style: italic;
  line-height: 22px;
}
.yv-image {
  flex: none;
  width: 100%;
  max-width: 360px;
  height: 120px;
  border-radius: 16px;
  object-fit: cover;
}
.yv-back-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.yv-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.yv-circle {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1.5px solid var(--md-outline-variant);
  border-radius: 50%;
  background: var(--md-surface);
  color: var(--md-on-surface);
}
.yv-circle:hover:not(:disabled) {
  border-color: var(--md-primary);
  color: var(--md-primary);
}
.yv-circle:disabled {
  opacity: 0.38;
  cursor: default;
}
.yv-flip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--md-primary);
  color: #fff;
  font: 700 16px/20px var(--font-app-bold);
}
.yv-flip:hover {
  background: var(--md-hero);
}
.yv-keys {
  color: var(--md-on-surface-variant);
  font-size: 13px;
  text-align: center;
}

/* The card index (desktop): every card, the current one marked; jumps on click. */
.yv-aside {
  position: sticky;
  top: 88px;
  min-width: 0;
}
.yv-index {
  display: grid;
  gap: 10px;
  padding: 18px 12px 12px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 20px;
  background: var(--md-surface);
  box-shadow: var(--yv-shadow);
}
.yv-index-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}
.yv-index-head h2 {
  font: 700 16px/22px var(--font-app-bold);
}
.yv-index-head span {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--md-primary-container);
  color: var(--yv-on-primary-container);
  font: 700 12px/18px var(--font-app-bold);
  text-align: center;
}
.yv-index-list {
  display: grid;
  gap: 2px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.yv-index-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 6px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--md-on-surface);
  font: inherit;
  text-align: left;
}
.yv-index-item:hover {
  background: var(--yv-surface-container);
}
.yv-index-item[aria-current="true"] {
  background: var(--md-primary-container);
  box-shadow: inset 3px 0 0 var(--md-primary);
}
.yv-index-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--yv-surface-container);
  color: var(--md-on-surface-variant);
  font: 700 12px/16px var(--font-app-bold);
}
.yv-index-item[aria-current="true"] .yv-index-n {
  background: var(--md-primary);
  color: #fff;
}
.yv-index-text {
  display: grid;
  min-width: 0;
}
.yv-index-text > span,
.yv-index-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.yv-index-text > span {
  font: 600 15px/20px var(--font-app);
}
.yv-index-text small {
  color: var(--md-on-surface-variant);
  font-size: 13px;
  line-height: 18px;
}

/* ---------- Danh sách: the table ---------- */
.yv-table-card {
  overflow: hidden;
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  background: var(--md-surface);
  box-shadow: var(--yv-shadow);
}
.yv-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.yv-table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-divider);
  background: var(--yv-surface-container);
  color: var(--md-on-surface-variant);
  font: 600 13px/18px var(--font-app);
  text-align: left;
}
.yv-table th:nth-child(1) {
  width: 32%;
}
.yv-table th:nth-child(3) {
  width: 22%;
}
.yv-table th:nth-child(4) {
  width: 112px;
}
.yv-table td {
  padding: 6px 16px;
  border-bottom: 1px solid var(--md-divider);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
.yv-table tbody tr {
  cursor: pointer;
}
.yv-table tbody tr:last-child td {
  border-bottom: 0;
}
.yv-table tbody tr:hover {
  background: #eef3f280;
}
.yv-word-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--md-on-surface);
  font: 700 16px/22px var(--font-app-bold);
  text-align: left;
  overflow-wrap: anywhere;
}
.yv-word-link:hover {
  color: var(--md-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.yv-row-type {
  margin-left: 6px;
  color: var(--md-outline);
  font-size: 12px;
  line-height: 16px;
}
.yv-row-phon {
  display: block;
  margin: -8px 0 6px;
  color: var(--md-on-surface-variant);
  font-size: 13px;
  line-height: 18px;
}
.yv-td-meaning {
  color: var(--md-on-surface-variant);
  font-size: 15px;
}
.yv-td-source {
  color: var(--md-on-surface-variant);
  font-size: 13px;
}
.yv-source-link {
  color: var(--yv-link);
  font-weight: 600;
}
.yv-source-link:hover {
  text-decoration: underline;
}
.yv-td-actions {
  white-space: nowrap;
  text-align: right;
}
.yv-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--yv-link);
}
.yv-icon:hover {
  background: var(--md-primary-container);
}
.yv-icon.is-delete {
  color: var(--md-outline);
}
.yv-icon.is-delete:hover {
  background: var(--yv-error-container);
  color: var(--yv-error);
}

/* ---------- dialogs: add, example, delete (the dictionary is dictionary.css) ---------- */
dialog.yv-dialog {
  font-family: var(--font-app);
  color: var(--md-on-surface);
}
dialog.yv-add-dialog {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  padding: 28px 32px;
}
.yv-dialog h2 {
  margin: 0 0 6px;
  font: 700 22px/28px var(--font-app-bold);
}
.yv-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.yv-dialog-head p {
  margin: 0;
}
.yv-dialog-close {
  flex: none;
  margin: -6px -10px 0 0;
}
.yv-form {
  display: grid;
}
.yv-field label,
.yv-extras legend {
  margin: 14px 0 6px;
  color: var(--md-on-surface-variant);
  font: 600 14px/18px var(--font-app);
}
.yv-field input,
.yv-field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 14px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font: 400 15px/22px var(--font-app);
}
.yv-field textarea {
  display: block;
  resize: vertical;
}
.yv-field input::placeholder,
.yv-field textarea::placeholder,
.yv-answer::placeholder {
  color: var(--md-outline);
}
.yv-field [aria-invalid="true"] {
  border-color: var(--yv-error);
}
.yv-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 10px;
}
.yv-field-error,
.yv-form-error {
  margin: 4px 0 0;
  color: var(--yv-error);
  font-size: 13px;
  line-height: 18px;
}
.yv-field-error:empty,
.yv-form-error:empty {
  display: none;
}
.yv-extras {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.yv-extras legend {
  float: left;
  width: 100%;
  margin-bottom: 0;
  padding: 0;
}
.yv-examples .yv-field label {
  margin-top: 4px;
}
.yv-preview {
  margin: 0;
}
.yv-preview img {
  display: block;
  width: 100%;
  height: 86px;
  border-radius: 14px;
  object-fit: cover;
}
.yv-extras-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
dialog.yv-dialog .dialog-actions {
  margin-top: 20px;
}
dialog.yv-example-dialog textarea {
  margin-top: 8px;
}
.yv-delete p strong {
  color: var(--md-on-surface);
}
.button.yv-danger {
  background: #ba1a1a;
}
.button.yv-danger:hover {
  background: #93000a;
}

/* ---------- narrow desktop, tablet and phone: one column, no card index ---------- */
@media (max-width: 1279px) {
  .yv-cards {
    grid-template-columns: minmax(0, 1fr);
  }
  .yv-aside {
    display: none;
  }
}
@media (max-width: 767px) {
  .yv-page {
    gap: 14px;
  }
  .yv-head {
    gap: 12px;
  }
  .yv-intro p:first-child {
    display: none;
  }
  .yv-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }
  .yv-seg {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .yv-search {
    flex: none;
  }
  .yv-add {
    width: 50px;
    padding: 0;
  }
  .yv-add span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .yv-study {
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }
  /* The card, its arrows and "Lật thẻ" fit above the bottom bar. */
  .yv-card {
    height: clamp(300px, calc(100svh - 470px), 460px);
  }
  .yv-face {
    padding: 22px 18px;
  }
  .yv-word {
    font-size: 32px;
    line-height: 40px;
  }
  .yv-keys {
    display: none;
  }
  .yv-controls {
    padding: 0 4px;
  }
  .yv-empty {
    border: 0;
    background: none;
    box-shadow: none;
  }
  /* The table as the app's list: word + type, meaning, source; speaker and bin on the right. */
  .yv-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .yv-table,
  .yv-table tbody {
    display: block;
  }
  .yv-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "word actions" "meaning actions";
    align-items: center;
    padding: 6px 4px 8px 14px;
    border-bottom: 1px solid var(--md-divider);
  }
  .yv-table tbody tr:last-child {
    border-bottom: 0;
  }
  .yv-table td {
    display: block;
    padding: 0;
    border: 0;
  }
  .yv-td-word {
    grid-area: word;
  }
  /* The word keeps a 44 px target; the meaning tucks under it like the app's two-line row. */
  .yv-word-link {
    margin-bottom: -10px;
  }
  .yv-td-meaning {
    grid-area: meaning;
    font-size: 13px;
    line-height: 18px;
  }
  /* Like the app's rows: no phonetic or source line on phones. */
  .yv-table .yv-td-source,
  .yv-row-phon {
    display: none;
  }
  .yv-td-actions {
    grid-area: actions;
    display: flex;
  }
  dialog.yv-add-dialog {
    padding: 24px 20px;
  }
}

/* ---------- motion (the flip and the card change), only when it is welcome ---------- */
@media (prefers-reduced-motion: no-preference) {
  .yv-card-inner {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .yv-card.is-from-next {
    animation: yv-from-next 0.22s ease-out;
  }
  .yv-card.is-from-prev {
    animation: yv-from-prev 0.22s ease-out;
  }
  .yv-pill,
  .yv-circle,
  .yv-index-item,
  .yv-seg-btn {
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  }
}
@keyframes yv-from-next {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
}
@keyframes yv-from-prev {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }
}
