/* Компактная тема — меньше шрифты, кнопки и отступы */
:root {
  --app-sidebar-width: 15.5rem;
  --app-topbar-height: 2.75rem;
  --app-shell-offset: 3.25rem;

  /* Japanese-inspired palette */
  --jp-indigo: #3f5f4a;
  --jp-indigo-strong: #324d3c;
  --jp-vermilion: #d9482f;
  --jp-vermilion-strong: #bf3d26;
  --jp-warm-paper: #fcfaf4;
  --jp-warm-bg: #fdfbf7;
  --jp-warm-border: #dfd5c3;
  --jp-warm-text: #2e2a22;
  --jp-muted: #786f60;

  --bs-body-font-size: 0.875rem;
  --bs-body-line-height: 1.4;

  --bs-body-color: var(--jp-warm-text);
  --bs-secondary-color: var(--jp-muted);
  --bs-border-color: var(--jp-warm-border);
  --bs-link-color: var(--jp-indigo);
  --bs-link-hover-color: var(--jp-indigo-strong);
  --bs-primary: var(--jp-indigo);
  --bs-primary-rgb: 36, 58, 115;
  --bs-danger: var(--jp-vermilion);
  --bs-danger-rgb: 217, 72, 47;
  --bs-border-radius: 0.45rem;
  --bs-border-radius-sm: 0.35rem;
  --bs-border-radius-lg: 0.6rem;

  --bs-btn-padding-y: 0.2rem;
  --bs-btn-padding-x: 0.55rem;
  --bs-btn-font-size: 0.8125rem;
  --bs-btn-line-height: 1.35;
  --bs-btn-border-radius: 0.25rem;

  --bs-border-radius: 0.25rem;
  --bs-border-radius-sm: 0.2rem;
  --bs-border-radius-lg: 0.3rem;

  --bs-nav-link-padding-y: 0.2rem;
  --bs-nav-link-padding-x: 0.45rem;
  --bs-nav-link-font-size: 0.875rem;

  --bs-navbar-padding-y: 0.3rem;
  --bs-navbar-brand-font-size: 1rem;

  --bs-card-spacer-y: 0.65rem;
  --bs-card-spacer-x: 0.85rem;
  --bs-card-title-spacer-y: 0.35rem;
  --bs-card-cap-padding-y: 0.45rem;
  --bs-card-cap-padding-x: 0.85rem;

  --bs-input-btn-padding-y: 0.2rem;
  --bs-input-btn-padding-x: 0.5rem;
  --bs-input-btn-font-size: 0.8125rem;

  --bs-form-control-padding-y: 0.25rem;
  --bs-form-control-padding-x: 0.5rem;
  --bs-form-control-font-size: 0.875rem;

  --bs-badge-font-size: 0.7rem;
  --bs-badge-padding-y: 0.25em;
  --bs-badge-padding-x: 0.45em;

  --bs-gutter-x: 1rem;
}

html {
  min-height: 100%;
  font-size: 14px;
}

body {
  margin-bottom: 0;
}

.app-body {
  background-color: var(--jp-warm-bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(89, 79, 61, 0.03) 1px, transparent 0),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  background-size: 14px 14px, 100% 100%;
  color: var(--jp-warm-text);
  font-family: "Inter", "Noto Sans JP", "Yu Gothic UI", "Meiryo", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--app-topbar-height);
  background-color: rgba(248, 244, 234, 0.9) !important;
  backdrop-filter: saturate(110%) blur(2px);
  box-shadow: 0 0.12rem 0.5rem rgba(54, 46, 34, 0.08);
}

.app-topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  height: 100%;
  padding: 0 0.65rem;
}

.app-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: #212529;
  text-decoration: none;
}

.app-menu-btn:hover,
.app-menu-btn:focus-visible {
  color: var(--jp-indigo);
}

.app-menu-icon {
  display: block;
  width: 1.25rem;
  height: 1rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100%;
}

.app-brand {
  font-size: 1rem;
  font-weight: 600;
  color: var(--jp-indigo);
  text-decoration: none;
  white-space: nowrap;
}

.app-brand:hover {
  color: var(--jp-indigo-strong);
}

.app-topbar-greeting {
  font-size: 0.8125rem;
  color: #495057;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
}

.app-topbar-greeting-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
  max-width: min(30rem, 70vw);
}

.app-topbar-profile-link {
  flex-shrink: 0;
  font-weight: 500;
  text-decoration: none;
  color: var(--jp-indigo);
  white-space: nowrap;
}

.app-topbar-demo-badge {
  flex-shrink: 0;
}

.app-topbar-profile-link:visited {
  color: var(--jp-indigo);
}

.app-topbar-profile-link:hover,
.app-topbar-profile-link:focus {
  color: var(--jp-indigo-strong);
  text-decoration: underline;
}

.app-topbar-logout-form {
  flex-shrink: 0;
  margin: 0;
}

@media (max-width: 575.98px) {
  .app-topbar-user {
    gap: 0.35rem;
    max-width: calc(100vw - 8.75rem);
  }

  .app-topbar-greeting {
    gap: 0.25rem;
  }

  .app-topbar-greeting-text {
    max-width: 8rem;
    font-size: 0.75rem;
  }

  .app-topbar-profile-link {
    font-size: 0.75rem;
  }

  .app-topbar-demo-badge {
    display: none;
  }
}

@media (max-width: 420px) {
  .app-topbar-greeting-text {
    display: none;
  }
}

.card,
.modal-content,
.offcanvas {
  border-color: var(--jp-warm-border);
  background-color: var(--jp-warm-paper);
  box-shadow: 0 0.18rem 0.55rem rgba(63, 54, 40, 0.06);
}

.btn {
  border-radius: 0.45rem;
}

.btn-primary {
  --bs-btn-bg: var(--jp-indigo);
  --bs-btn-border-color: var(--jp-indigo);
  --bs-btn-hover-bg: var(--jp-indigo-strong);
  --bs-btn-hover-border-color: var(--jp-indigo-strong);
}

.btn-danger {
  --bs-btn-bg: var(--jp-vermilion);
  --bs-btn-border-color: var(--jp-vermilion);
  --bs-btn-hover-bg: var(--jp-vermilion-strong);
  --bs-btn-hover-border-color: var(--jp-vermilion-strong);
}

.btn-outline-primary {
  --bs-btn-color: var(--jp-indigo);
  --bs-btn-border-color: #6e7fa8;
  --bs-btn-hover-bg: var(--jp-indigo);
  --bs-btn-hover-border-color: var(--jp-indigo);
}

.badge.bg-secondary,
.text-bg-secondary {
  background-color: #d7d0c0 !important;
  color: #4f4638 !important;
}

.form-control,
.form-select {
  background-color: #fffdf7;
  border-color: var(--jp-warm-border);
}

.form-control:focus,
.form-select:focus {
  border-color: #8b9bc2;
  box-shadow: 0 0 0 0.18rem rgba(36, 58, 115, 0.16);
}

.kana-char,
.lesson-token,
.kanji-ref-btn {
  font-family: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
}

.kanji-ref-btn:hover {
  border-color: #adb5bd;
  background: #f1f3f5;
}

.app-content {
  padding-top: 0.75rem;
}

.app-sidebar {
  width: var(--app-sidebar-width);
}

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-sidebar-link {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: var(--bs-border-radius);
  color: #212529;
  text-decoration: none;
  font-size: 0.875rem;
}

.app-sidebar-link:hover {
  background-color: #f1f3f5;
  color: #212529;
}

.app-sidebar-link.active {
  background-color: #e4ede6;
  color: var(--jp-indigo-strong);
  font-weight: 500;
  border: 1px solid #c4d3c8;
}

.app-sidebar-section {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a8478;
  padding: 0.35rem 0.5rem 0.15rem;
}

.app-sidebar-group {
  margin-top: 0.5rem;
}

.app-sidebar-group:first-child {
  margin-top: 0;
}

.app-sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a8478;
  padding: 0.35rem 0.5rem 0.2rem;
  cursor: pointer;
  text-align: left;
  border-radius: var(--bs-border-radius);
}

.app-sidebar-section-toggle:hover,
.app-sidebar-section-toggle:focus-visible {
  color: #5c574c;
  background-color: #f1f3f5;
  outline: none;
}

.app-sidebar-chevron {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-top: -0.15rem;
}

.app-sidebar-group.is-collapsed .app-sidebar-chevron {
  transform: rotate(-45deg);
  margin-top: 0.1rem;
}

.app-sidebar-group-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-sidebar-group.is-collapsed .app-sidebar-group-body {
  display: none;
}

.admin-sidebar .app-sidebar-group-body.list-group {
  gap: 0;
}

.admin-sidebar .app-sidebar-group {
  margin-bottom: 0.25rem;
}

.app-sidebar-hint {
  display: block;
  font-size: 0.75rem;
  color: #6c757d;
  line-height: 1.35;
}

h1, .h1 { font-size: 1.35rem; margin-bottom: 0.5rem; }
h2, .h2 { font-size: 1.15rem; margin-bottom: 0.45rem; }
h3, .h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
h4, .h4 { font-size: 1rem; }
h5, .h5 { font-size: 0.9375rem; }
h6, .h6 { font-size: 0.875rem; }

.lead {
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

.display-4 {
  font-size: 1.5rem !important;
  line-height: 1.25;
}

.display-5 {
  font-size: 1.25rem !important;
}

.display-6 {
  font-size: 1.1rem !important;
  margin-bottom: 0;
}

.btn-lg,
.btn-group-lg > .btn {
  --bs-btn-padding-y: 0.3rem;
  --bs-btn-padding-x: 0.65rem;
  --bs-btn-font-size: 0.875rem;
}

.btn-sm,
.btn-group-sm > .btn {
  --bs-btn-padding-y: 0.15rem;
  --bs-btn-padding-x: 0.4rem;
  --bs-btn-font-size: 0.75rem;
}

.navbar-brand {
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
}

main {
  padding-top: 0.25rem;
}

.mb-3 { margin-bottom: 0.65rem !important; }
.mb-4 { margin-bottom: 0.85rem !important; }
.mb-5 { margin-bottom: 1.25rem !important; }
.mt-4 { margin-top: 0.85rem !important; }
.mt-5 { margin-top: 1.25rem !important; }
.py-4 { padding-top: 0.85rem !important; padding-bottom: 0.85rem !important; }
.py-5 { padding-top: 1.25rem !important; padding-bottom: 1.25rem !important; }

.gap-2 { gap: 0.35rem !important; }
.g-3 { --bs-gutter-y: 0.65rem; --bs-gutter-x: 0.65rem; }

.list-group-item {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.table {
  font-size: 0.8125rem;
}

.table > :not(caption) > * > * {
  padding: 0.35rem 0.5rem;
}

.nav-tabs .nav-link {
  padding: 0.3rem 0.65rem;
  font-size: 0.875rem;
}

.form-label {
  margin-bottom: 0.2rem;
  font-size: 0.8125rem;
}

.form-text {
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 0.65rem 0.85rem;
}

.modal-title {
  font-size: 1rem;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.2rem rgba(63, 95, 74, 0.35);
}

.lesson-token {
  cursor: pointer;
  display: inline-block;
  padding: 0.08rem 0.35rem;
  margin: 0 0.12rem;
  border: 1px solid #ced4da;
  border-radius: 0.3rem;
  background: #f8f9fa;
  color: #212529;
  box-shadow: 0 0.1rem 0.25rem rgba(0, 0, 0, 0.08);
  line-height: 1.35;
  vertical-align: baseline;
  text-decoration: none;
}

.lesson-token:hover {
  background: #f1f3f5;
  border-color: #adb5bd;
  box-shadow: 0 0.12rem 0.35rem rgba(0, 0, 0, 0.12);
}

.lesson-token.is-active {
  background: #e9ecef;
  border-color: #868e96;
  box-shadow: 0 0.15rem 0.4rem rgba(0, 0, 0, 0.14);
}

.token-popover {
  position: fixed;
  z-index: 1080;
  width: min(17rem, calc(100vw - 1rem));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 0.75rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.55rem 0.65rem 0.6rem;
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
  border: 1px solid #ced4da;
  border-radius: 0.4rem;
  background: #fff;
  box-shadow: 0 0.25rem 0.85rem rgba(0, 0, 0, 0.14);
}

.token-popover.token-popover--strokes {
  width: min(19rem, calc(100vw - 1rem));
}

.token-popover.token-popover--strokes-mobile {
  width: min(18rem, calc(100vw - 0.75rem));
}

.token-popover-strokes {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.15rem 0 0.45rem;
  padding-right: 1.1rem;
}

.token-stroke-writer-target {
  width: 128px;
  height: 128px;
  max-width: 100%;
  line-height: 0;
}

.token-popover-strokes--kanji-card .token-stroke-writer-target {
  border: 1px solid #dee2e6;
  background: #fff;
}

.token-stroke-writer-target svg,
.token-stroke-writer-target .token-stroke-writer-svg {
  display: block;
}

.token-stroke-unavailable {
  text-align: center;
  padding: 0.35rem 0.25rem;
}

.token-popover-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0.35rem;
}

@media (max-width: 575.98px) {
  .token-popover.token-popover--strokes {
    width: min(18rem, calc(100vw - 0.75rem));
  }

  .token-popover-strokes {
    padding-right: 0;
  }

  .token-stroke-writer-target {
    width: 104px;
    height: 104px;
  }

  .token-popover-close {
    top: 0.25rem;
    right: 0.25rem;
    width: 2rem;
    height: 2rem;
  }

  .kanji-ref-btn,
  .lexicon-link-chip {
    min-height: 2.25rem;
  }

  .vocab-ref-card.kanji-ref-btn .card-body {
    padding: 0.5rem 0.35rem;
  }
}

.token-popover-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  padding-right: 1.25rem;
  margin-bottom: 0.35rem;
}

.token-popover-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.35rem;
}

.token-popover-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6c757d;
}

.token-popover-value {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: #212529;
}

.token-popover-audio {
  width: 100%;
  height: 2rem;
  margin-top: 0.45rem;
}

.lexicon-link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.lexicon-link-chips--compact {
  justify-content: center;
}

.lexicon-link-chip {
  border: 1px solid #c4d3c8;
  background: #f4f8f5;
  color: var(--jp-indigo-strong);
  border-radius: 0.35rem;
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 0.1rem 0.35rem;
  cursor: pointer;
}

.lexicon-link-chip:hover,
.lexicon-link-chip:focus-visible {
  background: #e4ede6;
  outline: none;
}

.lexicon-link-chip--word {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kanji-ref-readings {
  font-size: 0.62rem;
  line-height: 1.25;
}

.lexicon-section {
    scroll-margin-top: 1rem;
}

.lexicon-section.lexicon-search-loading {
    opacity: 0.65;
    pointer-events: none;
}

.lexicon-section + .lexicon-section {
  border-top: 1px solid var(--jp-warm-border);
  padding-top: 1rem;
}

.lesson-content mark {
  padding: 0.05rem 0.15rem;
  border-radius: 0.15rem;
}

.lesson-content mark.hl-yellow { background: #fff3cd; }
.lesson-content mark.hl-green { background: #d1e7dd; }
.lesson-content mark.hl-blue { background: #cfe2ff; }
.lesson-content mark.hl-pink { background: #f8d7da; }
.lesson-content mark.hl-orange { background: #ffe5cc; }

.lesson-content ul,
.lesson-content ol {
  margin: 0.35rem 0;
  padding-left: 1.35rem;
}

.lesson-content ul {
  list-style-type: circle;
}

.lesson-content ol {
  list-style-type: decimal;
}

.lesson-content li {
  margin: 0.15rem 0;
}

.lesson-content p.text-left { text-align: left; }
.lesson-content p.text-center { text-align: center; }
.lesson-content p.text-right { text-align: right; }
.lesson-content li.text-left { text-align: left; }
.lesson-content li.text-center { text-align: center; }
.lesson-content li.text-right { text-align: right; }

.lesson-block {
  margin-bottom: 0.85rem !important;
}

.lesson-block-type-heading,
.lesson-block-type-label {
  font-weight: 700;
  color: #1f2937;
}

.lesson-block-type-heading {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.module-card {
  transition: transform 0.15s ease;
}

.module-card:hover {
  transform: translateY(-1px);
}

.module-card .card-body {
  padding: 0.65rem 0.85rem;
}

.match-game-hud .card-body {
  background: #faf7f0;
}

.match-game-timer-seconds {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #3d4a3e;
}

.match-game-timer-track {
  height: 0.85rem;
  border-radius: 999px;
  background: #e8e0d4;
  overflow: hidden;
  border: 1px solid #d8d0c4;
}

.match-game-timer-track--low {
  border-color: #d4a8a0;
  background: #f0e4e2;
}

.match-game-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5a7a5a, #6b8f6b);
  transition: width 0.38s ease, background-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.match-game-timer-track--low .match-game-timer-fill {
  background: linear-gradient(90deg, #b54a3a, #c96a52);
}

.match-game-timer-fill--bonus {
  background: linear-gradient(90deg, #3d7a4a, #52a060);
  box-shadow: 0 0 0.45rem rgba(61, 122, 74, 0.45);
}

.match-game-timer-fill--penalty {
  background: linear-gradient(90deg, #b54a3a, #c45c4a);
  box-shadow: 0 0 0.4rem rgba(181, 74, 58, 0.4);
}

.match-game-arena--ended {
  opacity: 0.72;
  pointer-events: none;
}

.match-game-arena--waiting {
  pointer-events: none;
  opacity: 0.88;
}

.match-game-arena {
  position: relative;
  min-height: min(68vh, 520px);
  height: min(72vh, 560px);
  border: 1px solid #d8d0c4;
  border-radius: 0.5rem;
  background:
    radial-gradient(circle at 12% 18%, rgba(90, 122, 90, 0.08), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(74, 95, 122, 0.07), transparent 40%),
    #faf7f0;
  overflow: hidden;
  touch-action: none;
}

.match-game-tile {
  position: absolute;
  min-width: 7.5rem;
  max-width: 11.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #c9bfb0;
  border-radius: 0.4rem;
  background: #fff;
  box-shadow: 0 0.12rem 0.35rem rgba(45, 42, 38, 0.1);
  font-size: 0.92rem;
  line-height: 1.35;
  text-align: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  z-index: 1;
}

.match-game-tile:focus-visible {
  outline: 2px solid #5a7a5a;
  outline-offset: 2px;
}

.match-game-tile.is-dragging {
  cursor: grabbing;
  transform: scale(1.04);
  box-shadow: 0 0.35rem 0.85rem rgba(45, 42, 38, 0.18);
  border-color: #5a7a5a;
}

.match-game-tile.match-game-tile--drop-target {
  border-color: #4a5f7a;
  box-shadow: 0 0 0 2px rgba(74, 95, 122, 0.35);
  transform: scale(1.02);
}

.match-game-tile.is-returning {
  transition: left 0.28s ease, top 0.28s ease;
}

.match-game-tile.is-wrong {
  animation: match-game-shake 0.42s ease;
  border-color: #c45c4a;
}

.match-game-tile.is-vanishing {
  animation: match-game-vanish 0.42s ease forwards;
  pointer-events: none;
}

.conjugation-prompt {
  font-family: var(--bs-font-sans-serif);
  letter-spacing: 0.02em;
}

.conjugation-option-btn {
  min-height: 3rem;
  font-size: 1.05rem;
}

.study-list-star {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 2;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  color: var(--bs-secondary-color);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--bs-border-color);
}

.study-list-star.is-active {
  color: #b8860b;
  border-color: #d4a017;
}

.site-footer-version {
  opacity: 0.85;
}

.word-search-target--found {
  text-decoration: line-through;
  opacity: 0.55;
}

@keyframes ws-hint-pulse {
  50% {
    transform: scale(1.06);
  }
}

@keyframes match-game-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@keyframes match-game-vanish {
  to {
    opacity: 0;
    transform: scale(0.6);
  }
}

.kana-char {
  font-size: 1.35rem;
  line-height: 1.2;
}

.review-card {
  max-width: 560px;
  margin: 0 auto;
}

.review-card .card-body {
  padding: 0.85rem;
}

.review-card audio,
.review-flip__audio {
  max-height: 32px;
}

.review-front {
  font-family: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 1.85rem;
  line-height: 1.35;
  font-weight: 500;
}

.review-flip-type {
  font-size: 0.78rem;
  padding: 0.35em 0.55em;
}

.review-flip-scene {
  perspective: 960px;
}

.review-flip {
  width: 100%;
  min-height: 14.5rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.review-flip:focus-visible {
  outline: 2px solid var(--jp-indigo);
  outline-offset: 4px;
  border-radius: var(--bs-border-radius-lg);
}

.review-flip__inner {
  position: relative;
  width: 100%;
  min-height: 14.5rem;
  transform-style: preserve-3d;
  transition: transform 0.55s ease;
}

.review-flip.is-flipped .review-flip__inner {
  transform: rotateY(180deg);
}

.review-flip__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.1rem 1rem;
  backface-visibility: hidden;
  border: 1px solid var(--jp-warm-border);
  border-radius: var(--bs-border-radius-lg);
  background: var(--jp-warm-paper);
  box-shadow: 0 0.2rem 0.55rem rgba(46, 42, 34, 0.08);
}

.review-flip__face--front {
  transform: rotateY(0deg);
}

.review-flip__face--back {
  transform: rotateY(180deg);
  background: linear-gradient(165deg, #f7f3ea 0%, #eef4ef 100%);
}

.review-back-label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--jp-muted);
}

.review-back {
  font-family: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 1.45rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.review-flip:not(.is-flipped):hover .review-flip__face--front {
  border-color: var(--jp-indigo);
}

@media (prefers-reduced-motion: reduce) {
  .review-flip__inner {
    transition: none;
  }
}

.admin-stat-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.08);
  border-color: var(--jp-indigo);
}

.admin-uniform-btn {
  min-width: 7.5rem;
  text-align: center;
}

html:has(body.admin-ui) {
  overflow-x: hidden;
}

.admin-ui {
  overflow-x: hidden;
  max-width: 100vw;
}

.admin-ui .container {
  max-width: 100%;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  overflow-x: hidden;
}

.admin-ui .row {
  --bs-gutter-x: 0.75rem;
  max-width: 100%;
  margin-left: calc(var(--bs-gutter-x) * -0.5);
  margin-right: calc(var(--bs-gutter-x) * -0.5);
}

.admin-ui .row > [class*="col-"] {
  min-width: 0;
  max-width: 100%;
}

.admin-ui .admin-page-content,
.admin-ui .admin-sidebar {
  min-width: 0;
  max-width: 100%;
}

.admin-ui .admin-page-scroll {
  min-width: 0;
  max-width: 100%;
}

.admin-ui .admin-table-responsive,
.admin-ui .table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.admin-ui .admin-table-responsive > .table,
.admin-ui .table-responsive > .table {
  margin-bottom: 0;
}

.admin-ui .admin-topbar .container-fluid {
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 991.98px) {
  .admin-ui .admin-table-responsive > .table,
  .admin-ui .table-responsive > .table {
    width: max-content;
    min-width: 100%;
  }

  .admin-ui .admin-table-responsive > .table td,
  .admin-ui .admin-table-responsive > .table th,
  .admin-ui .table-responsive > .table td,
  .admin-ui .table-responsive > .table th {
    white-space: nowrap;
  }

  .admin-ui .admin-table-responsive > .table td.allow-wrap,
  .admin-ui .admin-table-responsive > .table td.small,
  .admin-ui .admin-table-responsive > .table td:has(.badge),
  .admin-ui .table-responsive > .table td.allow-wrap,
  .admin-ui .table-responsive > .table td.small,
  .admin-ui .table-responsive > .table td:has(.badge) {
    white-space: normal;
    max-width: 12rem;
  }

  .admin-ui .admin-uniform-btn,
  .admin-ui .btn.btn-sm {
    min-width: auto;
    padding: 0.25rem 0.55rem;
    font-size: 0.8125rem;
  }

  .admin-ui .d-flex.justify-content-between,
  .admin-ui .d-flex.justify-content-between.align-items-center {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .admin-ui .admin-topbar .navbar-brand {
    font-size: 1rem;
    max-width: 100%;
  }

  .admin-ui .admin-topbar .d-flex {
    width: 100%;
    justify-content: flex-start;
  }

  .admin-ui .admin-sidebar {
    margin-bottom: 0.75rem;
  }

  .admin-ui .card .row.g-2 > [class*="col-"],
  .admin-ui form.row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .admin-ui .table .btn-sm {
    white-space: nowrap;
  }
}

.admin-ui .btn.btn-sm {
  min-width: 7.5rem;
  text-align: center;
}

.admin-ui .lesson-editor-toolbar .btn,
.admin-ui .lesson-editor-toolbar .btn.btn-sm,
.admin-ui .card-header .d-flex.gap-1 .btn,
.admin-ui .card-header .d-flex.gap-1 .btn.btn-sm {
  min-width: auto;
}

/* Иконки/стрелки в списках не растягиваем. */
.admin-ui .btn.btn-sm.py-0,
.admin-ui .btn.btn-sm.px-1,
.admin-ui .btn.btn-sm.btn-close,
.admin-ui .btn.btn-sm[title="Выше"],
.admin-ui .btn.btn-sm[title="Ниже"] {
  min-width: auto;
}

.module-lesson-layout {
  --module-lesson-list-width: 17.5rem;
  display: grid;
  grid-template-columns: var(--module-lesson-list-width) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: stretch;
  min-height: 420px;
  transition: grid-template-columns 0.28s ease, gap 0.28s ease;
}

.module-lesson-layout.is-list-collapsed {
  --module-lesson-list-width: 0rem;
  gap: 0;
}

.module-lesson-sidebar-wrap {
  min-width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.28s ease;
  display: flex;
  flex-direction: column;
}

.module-lesson-sidebar-wrap .module-lesson-sidebar {
  flex: 1 1 auto;
}

.module-lesson-layout.is-list-collapsed .module-lesson-sidebar-wrap {
  opacity: 0;
  pointer-events: none;
}

.module-lesson-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.module-lesson-panel-header {
  background-color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.module-lesson-list-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.module-lesson-list-toggle-icon {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.module-lesson-layout.is-list-collapsed .module-lesson-list-toggle-icon {
  transform: rotate(-135deg);
}

.module-lesson-sidebar,
.module-lesson-panel {
  min-height: 360px;
}

.module-lesson-list .list-group-item {
  border-left: 0;
  border-right: 0;
}

.module-lesson-list .list-group-item.active {
  background-color: #e4ede6;
  border-color: #c4d3c8;
  color: var(--jp-indigo-strong);
}

.module-lesson-list .list-group-item.active small,
.module-lesson-list .list-group-item.active .text-white-50 {
  color: #5d725f !important;
}

.module-lesson-list .lesson-list-item--locked {
  opacity: 0.42;
  background-color: #f3efe6;
  pointer-events: none;
  cursor: not-allowed;
}

.module-lesson-list .lesson-list-item--locked.active {
  opacity: 0.65;
}

.lesson-start-gate {
  min-height: min(52vh, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.85rem;
  padding: 1.5rem 1rem;
}

.lesson-start-gate-form {
  margin-top: 0.35rem;
}

.module-lesson-panel .lesson-content {
  line-height: 1.6;
}

.lesson-quiz-start-wrap {
  display: flex;
  justify-content: flex-start;
}

#inlineLessonQuizPanel:not(.d-none) {
  min-height: 12rem;
}

@media (max-width: 991.98px) {
  .module-lesson-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.5rem;
    align-items: start;
  }

  .module-lesson-sidebar-wrap {
    max-height: min(70vh, 28rem);
    opacity: 1;
    pointer-events: auto;
  }

  .module-lesson-layout.is-list-collapsed .module-lesson-sidebar-wrap {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
  }

  .module-lesson-list-toggle--main {
    width: 100%;
    justify-content: center;
  }

  .module-lesson-panel-header {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .match-game-arena {
    min-height: 420px;
    height: 62vh;
  }
}

@media (min-width: 992px) {
  .module-lesson-list-toggle--sidebar {
    display: none !important;
  }
}

.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - var(--app-shell-offset));
  padding: 1.5rem 0;
}

.auth-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.35rem 1.5rem;
  border: 1px solid #dee2e6;
  border-radius: var(--bs-border-radius-lg);
  background-color: #fff;
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.06);
}

.auth-card .auth-title {
  text-align: center;
  margin-bottom: 0.75rem;
}

.auth-card h2 {
  text-align: center;
  font-size: 1rem;
  margin-bottom: 0;
}

.auth-card hr {
  margin: 0.65rem 0 0.85rem;
}

.auth-card .auth-footer {
  text-align: center;
  font-size: 0.8125rem;
}

.auth-card .auth-footer a {
  white-space: nowrap;
}

.guest-landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--app-shell-offset));
  padding: 1.5rem 0;
}

.guest-landing-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.35rem 1.5rem;
  text-align: center;
  border: 1px solid #dee2e6;
  border-radius: var(--bs-border-radius-lg);
  background-color: #fff;
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.06);
}

.guest-landing-card .guest-landing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.password-field-wrap {
  position: relative;
}

.password-field-wrap .password-toggle-input {
  padding-right: 2.35rem;
}

.password-field-wrap.form-floating > label {
  padding-right: 2.1rem;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0.15rem 0.25rem;
  line-height: 1;
  color: #6c757d;
  z-index: 5;
  cursor: pointer;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus-visible {
  color: #495057;
}

.password-toggle-btn:focus-visible {
  outline: 2px solid rgba(27, 110, 194, 0.35);
  outline-offset: 1px;
  border-radius: 0.2rem;
}

.password-toggle-btn svg {
  width: 1rem;
  height: 1rem;
  display: block;
  pointer-events: none;
}

/* Профиль — колонка по центру, умеренная ширина */
.profile-page {
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
}

.profile-card .card-body {
  padding: 0.65rem 0.85rem;
}

.profile-card .card-title {
  margin-bottom: 0.45rem;
}

.profile-field-narrow {
  max-width: 22rem;
}

.profile-field-inline {
  flex: 1 1 14rem;
  min-width: 0;
  max-width: 24rem;
}

.profile-email {
  word-break: break-all;
}

.profile-jlpt-select {
  width: auto;
  min-width: 7rem;
  max-width: 10rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: var(--bs-border-radius);
  background-color: #fff;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.profile-stat--wide {
  grid-column: 1 / -1;
}

.profile-stat dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6c757d;
}

.profile-stat dd {
  margin: 0;
  font-size: 0.875rem;
}

.profile-weakness-list .list-group-item {
  font-size: 0.8125rem;
}

@media (max-width: 575.98px) {
  .profile-page {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .profile-stats {
    grid-template-columns: 1fr;
  }

  .profile-field-narrow,
  .profile-field-inline {
    max-width: none;
  }
}

/* Final override: ensure primary is not bootstrap blue. */
.btn-primary {
  background-color: var(--jp-indigo) !important;
  border-color: var(--jp-indigo) !important;
  color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-check:checked + .btn-primary,
.btn-primary.active,
.show > .btn-primary.dropdown-toggle {
  background-color: var(--jp-indigo-strong) !important;
  border-color: var(--jp-indigo-strong) !important;
  color: #fff !important;
}

.btn-outline-primary {
  color: var(--jp-indigo) !important;
  border-color: #8a9f92 !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
  background-color: var(--jp-indigo) !important;
  border-color: var(--jp-indigo) !important;
  color: #fff !important;
}

.text-primary {
  color: var(--jp-indigo) !important;
}

.nav-tabs {
  border-bottom-color: #d8cebb;
}

.nav-tabs .nav-link {
  color: #5f6f62;
  border-color: transparent;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
  color: var(--jp-indigo);
  border-color: #e2d9c8 #e2d9c8 #d8cebb;
  background-color: #f9f5ec;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
  color: var(--jp-indigo-strong);
  background-color: #fcfaf4;
  border-color: #d8cebb #d8cebb #fcfaf4;
}

.lexicon-tabs {
  max-width: 28rem;
}

.lexicon-vocab-grid > .lexicon-vocab-col {
  flex: 0 0 auto;
  width: 100%;
}

@media (min-width: 576px) {
  .lexicon-vocab-grid > .lexicon-vocab-col {
    width: 50%;
  }
}

@media (min-width: 992px) {
  .lexicon-vocab-grid > .lexicon-vocab-col {
    width: 20%;
  }
}

.site-footer-feedback-link,
.site-footer-attributions-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #3d6a99;
  text-decoration: none;
  white-space: nowrap;
}

.site-footer-feedback-link:hover,
.site-footer-feedback-link:focus-visible,
.site-footer-attributions-link:hover,
.site-footer-attributions-link:focus-visible {
  color: #2f5580;
  text-decoration: underline;
}

.attributions-page .attributions-dl dt {
  color: var(--bs-secondary-color);
}

.attributions-edrdg-note {
  font-size: 0.9375rem;
}

.attributions-footer-note {
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.legal-page section + section {
  border-top: 1px solid var(--jp-warm-border);
  padding-top: 1.25rem;
}

.legal-page h2 {
  color: var(--jp-indigo);
}

.legal-page h3 {
  color: var(--jp-warm-text);
}

.legal-page ul {
  padding-left: 1.25rem;
}

.legal-page li + li {
  margin-top: 0.25rem;
}

.badge.bg-primary,
.text-bg-primary {
  background-color: var(--jp-indigo) !important;
  color: #fff !important;
}

.table a,
.table .btn-link {
  color: var(--jp-indigo);
}

.table a:hover,
.table .btn-link:hover {
  color: var(--jp-indigo-strong);
}

.vocab-ref-group-title {
  color: #3d4a3e;
  border-bottom: 1px solid #e0d8cc;
  padding-bottom: 0.35rem;
}

.vocab-ref-card {
  background: #fff;
  border-radius: 0.4rem;
  box-shadow: 0 0.1rem 0.3rem rgba(45, 42, 38, 0.08);
  transition: box-shadow 0.15s ease, transform 0.15s ease, opacity 0.2s ease;
  cursor: pointer;
}

.vocab-ref-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.2rem 0.45rem rgba(45, 42, 38, 0.12);
}

.vocab-ref-card--encountered {
  box-shadow: inset 3px 0 0 #5a7a5a, 0 0.1rem 0.3rem rgba(45, 42, 38, 0.08);
  background: linear-gradient(90deg, rgba(90, 122, 90, 0.1), #fff 38%);
}

.vocab-ref-card--unstudied {
  opacity: 0.38;
  filter: grayscale(0.25);
}

.vocab-ref-card--unstudied-soft {
  opacity: 0.78;
}

.vocab-ref-word {
  font-size: 1.05rem;
  line-height: 1.3;
}

.vocab-ref-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(90, 122, 90, 0.15);
  color: #3d5a3f;
}
