:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --ink: #1f1b16;
  --ink-2: #5b5349;
  --ink-3: #8c8378;
  --line: #e6dfd4;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6e9;
  --blue: #2563eb;
  --blue-soft: #e3ecfd;
  --green: #15803d;
  --green-soft: #dcf3e3;
  --amber: #b45309;
  --amber-soft: #fdf0d9;
  --red: #b91c1c;
  --red-soft: #fde4e4;
  --shadow: 0 1px 2px rgb(31 27 22 / 6%), 0 4px 16px rgb(31 27 22 / 6%);
  --radius: 14px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f;
    --surface: #1e1a16;
    --surface-2: #28231e;
    --ink: #f3ede4;
    --ink-2: #c3b9ab;
    --ink-3: #8f8577;
    --line: #353029;
    --accent: #ef4056;
    --accent-ink: #ffffff;
    --accent-soft: #3a1a1f;
    --blue: #7aa2ff;
    --blue-soft: #1c2740;
    --green: #4ade80;
    --green-soft: #15301f;
    --amber: #fbbf24;
    --amber-soft: #352a12;
    --red: #f87171;
    --red-soft: #3a1717;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: 1.7rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  margin: 28px 0 12px;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

textarea {
  resize: vertical;
}

input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: none;
}

.icon {
  display: inline-flex;
  flex: none;
}

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

.small {
  font-size: 0.85rem;
}

.error {
  color: var(--red);
}

.pad {
  padding: 24px;
}

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

.row.wrap {
  flex-wrap: wrap;
}

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

.row.between {
  justify-content: space-between;
}

.row.center {
  justify-content: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  padding: 4px 10px 18px;
}

.brand.big {
  font-size: 1.6rem;
  padding: 0;
  justify-content: center;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500;
}

.nav-link:hover {
  background: var(--surface-2);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.main {
  min-width: 0;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.page-head p {
  margin: 6px 0 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: 0.9rem;
}

.only-mobile {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-3);
}

.btn-ghost:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.btn-danger {
  background: var(--surface);
  color: var(--red);
  border-color: var(--line);
}

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

.btn-lg {
  padding: 13px 24px;
  font-size: 1.05rem;
  border-radius: 12px;
}

.btn.wide {
  width: 100%;
}

.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--ink-3);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  flex: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
}

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

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn.speak {
  color: var(--accent);
  vertical-align: middle;
  margin-left: 4px;
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.panel.warn {
  background: var(--amber-soft);
  border-color: transparent;
}

.panel.narrow {
  max-width: 560px;
}

.panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: middle;
}

.badge-s0 {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-s1,
.badge-s3 {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-s2 {
  background: var(--green-soft);
  color: var(--green);
}

.badge-hard {
  background: var(--red-soft);
  color: var(--red);
}

.badge-g-learning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-g-known {
  background: var(--green-soft);
  color: var(--green);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip {
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

span.chip {
  cursor: default;
}

.chip:hover {
  border-color: var(--ink-3);
}

.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.chip-hard {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--ink);
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.segmented button {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--ink-3);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

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

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs a,
.tabs button {
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  color: var(--ink-3);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}

.tabs .active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.spinner-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  padding: 24px 0;
  justify-content: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty {
  text-align: center;
  color: var(--ink-3);
  padding: 28px 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: calc(100vw - 32px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: var(--red);
  color: #fff;
}

.toast-success {
  background: var(--green);
  color: #fff;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 12 10 / 45%);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
  animation: fade 0.15s;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--surface);
  border-radius: 18px;
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgb(0 0 0 / 25%);
}

.modal-wide {
  width: min(720px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 6px 20px;
  gap: 8px;
}

.modal-head h3 {
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body {
  padding: 8px 20px 20px;
  overflow-y: auto;
}

.modal-body p {
  margin: 0;
}

.note-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-tr {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.pron {
  color: var(--ink-3);
  font-size: 0.95rem;
}

.spoken {
  color: var(--amber);
  font-weight: 500;
}

.spoken .label {
  color: var(--ink-3);
  font-weight: 400;
  font-size: 0.85rem;
}

.note-ru {
  font-size: 1.15rem;
}

.example {
  border-left: 3px solid var(--accent-soft);
  padding: 4px 0 4px 12px;
  font-style: italic;
}

.example > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.notes {
  font-size: 0.9rem;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #8f0b22 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.hero-label {
  opacity: 0.85;
  font-weight: 500;
}

.hero-number {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero-card .queue-counts .qc {
  background: rgb(255 255 255 / 18%);
  color: #fff;
}

.hero-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.hero-side .btn-primary {
  background: #fff;
  color: var(--accent);
}

.hero-card .done {
  font-weight: 700;
  font-size: 1.1rem;
}

.streak {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  opacity: 0.95;
}

.queue-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.qc {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.qc-new {
  background: var(--blue-soft);
  color: var(--blue);
}

.qc-learn {
  background: var(--amber-soft);
  color: var(--amber);
}

.qc-review {
  background: var(--green-soft);
  color: var(--green);
}

.quick-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 6px 14px;
  color: var(--ink-3);
}

.quick-add input {
  border: none;
  padding: 8px 4px;
  background: transparent;
}

.quick-add input:focus {
  box-shadow: none;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-num {
  font-size: 1.7rem;
  font-weight: 800;
}

.stat-label {
  color: var(--ink-3);
  font-size: 0.85rem;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
}

.bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  opacity: 0.85;
}

.bar.zero {
  background: var(--line);
}

.tile {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}

.tile:hover {
  border-color: var(--accent);
}

.tile .icon {
  color: var(--accent);
}

.tile p {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

.review-page {
  max-width: 640px;
  min-height: 100vh;
}

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

.review-head .queue-counts {
  margin: 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
}

.toggle.on {
  color: var(--accent);
  border-color: var(--accent);
}

.review-head .btn {
  padding: 7px 10px;
}

.review-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flashcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 24px 26px;
  box-shadow: var(--shadow);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
}

.card-front {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 20px 0;
}

.card-dir {
  color: var(--ink-3);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.card-tr-big {
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  word-break: break-word;
}

.card-ru-big {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.25;
}

.flashcard.revealed .note-tr {
  font-size: 2rem;
}

.type-answer {
  font-size: 1.15rem;
  text-align: center;
  padding: 12px;
}

.typed {
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
}

.typed-exact {
  background: var(--green-soft);
  color: var(--green);
}

.typed-close {
  background: var(--amber-soft);
  color: var(--amber);
}

.typed-wrong {
  background: var(--red-soft);
  color: var(--red);
}

.card-tools {
  margin-top: auto;
  padding-top: 6px;
}

.card-tools .btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.answer-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.rate-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.rate {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px 10px;
  border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
}

.rate-label {
  font-weight: 700;
}

.rate-interval {
  font-size: 0.8rem;
  opacity: 0.8;
}

.rate kbd {
  position: absolute;
  top: 5px;
  right: 8px;
  font-family: var(--mono);
  font-size: 0.65rem;
  opacity: 0.45;
}

.rate-again {
  background: var(--red-soft);
  color: var(--red);
}

.rate-hard {
  background: var(--amber-soft);
  color: var(--amber);
}

.rate-good {
  background: var(--green-soft);
  color: var(--green);
}

.rate-easy {
  background: var(--blue-soft);
  color: var(--blue);
}

.rate.suggested {
  border-color: currentColor;
}

.done-card {
  text-align: center;
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.done-emoji {
  font-size: 3rem;
}

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

.toolbar select {
  width: auto;
  max-width: 100%;
  flex: 1 1 200px;
}

.search {
  flex: 2 1 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--ink-3);
}

.search input {
  border: none;
  padding: 10px 0;
  background: transparent;
}

.search input:focus {
  box-shadow: none;
}

.word-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.word-list:empty {
  display: none;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

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

.word-row:hover {
  background: var(--surface-2);
}

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

.word-tr {
  font-weight: 700;
}

.word-ru {
  color: var(--ink-2);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.word-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.deck-group h2 {
  margin-top: 8px;
}

.deck-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  opacity: 0.75;
}

.deck-row.enabled {
  opacity: 1;
  border-color: var(--accent-soft);
}

.deck-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deck-title {
  color: var(--ink);
  font-weight: 600;
}

.deck-row .btn {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.progress {
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.2s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.import-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 55vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.import-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.import-row .badge {
  margin-left: 6px;
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-weight: 600;
}

.topic:hover {
  border-color: var(--ink-3);
}

.topic-learning {
  border-left-color: var(--amber);
}

.topic-known {
  border-left-color: var(--green);
}

.md {
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p,
.md ul,
.md ol {
  margin: 0.6em 0;
}

.md h1 {
  display: none;
}

.md h2 {
  margin: 1.6em 0 0.6em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.md h3 {
  margin: 1.3em 0 0.5em;
  font-size: 1.02rem;
}

.md table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
  margin: 0.8em 0;
}

.md th,
.md td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

.md th {
  background: var(--surface-2);
  font-weight: 700;
}

.md blockquote {
  margin: 0.8em 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 10px 10px 0;
}

.md pre {
  background: var(--surface-2);
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
}

.md pre code {
  background: none;
  padding: 0;
}

.doc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 24px 24px;
}

.doc p.line {
  margin: 0;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.doc p.line .icon-btn {
  width: 28px;
  height: 28px;
  vertical-align: middle;
}

.fab-explain {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 999px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
  cursor: pointer;
}

.fab-explain[hidden] {
  display: none;
}

.exercise {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise-q {
  font-size: 1.08rem;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.ex-num {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 0.8rem;
  color: var(--ink-3);
}

.exercise .row {
  flex-wrap: wrap;
}

.exercise .row input {
  flex: 1 1 200px;
}

.exercise .row .btn {
  padding: 9px 12px;
}

.verdict {
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.verdict p {
  margin: 4px 0 0;
  font-size: 0.93rem;
}

.verdict > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.verdict-head {
  font-weight: 800;
}

.verdict-correct {
  background: var(--green-soft);
}

.verdict-correct .verdict-head {
  color: var(--green);
}

.verdict-minor {
  background: var(--amber-soft);
}

.verdict-minor .verdict-head {
  color: var(--amber);
}

.verdict-wrong {
  background: var(--red-soft);
}

.verdict-wrong .verdict-head {
  color: var(--red);
}

.text-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.text-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
}

.text-item:hover {
  border-color: var(--accent);
}

.text-list .empty {
  grid-column: 1 / -1;
  padding: 12px;
  text-align: left;
}

.reader-tools .btn {
  padding: 7px 12px;
  font-size: 0.88rem;
}

.lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.line {
  padding: 8px 4px;
  border-bottom: 1px dashed var(--line);
}

.line:last-child {
  border-bottom: none;
}

.speaker {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.line-body {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}

.line-tr {
  font-size: 1.12rem;
  line-height: 1.7;
}

.line-tools {
  display: flex;
  flex: none;
}

.line-ru {
  color: var(--ink-2);
  font-size: 0.93rem;
  margin-top: 2px;
}

.w {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 1px;
}

.w:hover {
  background: var(--accent-soft);
}

.w.target {
  background: var(--amber-soft);
  box-shadow: inset 0 -2px 0 var(--amber);
}

.glossary {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gloss-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

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

.gloss-row .btn {
  padding: 6px 8px;
}

.questions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 22px;
  margin: 0;
}

.questions .answer {
  margin-top: 4px;
  font-weight: 600;
  color: var(--green);
}

.chat-page {
  max-width: 760px;
  min-height: 100vh;
  padding-bottom: 0;
}

.chat-page .page-head select {
  width: auto;
  max-width: 260px;
}

.chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 16px;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.typing {
  color: var(--ink-3);
  animation: blink 1s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

.chat-input {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 0 20px;
  background: linear-gradient(to bottom, transparent, var(--bg) 25%);
}

.chat-input textarea {
  min-height: 48px;
  max-height: 200px;
}

.send-btn {
  height: 48px;
  width: 52px;
  padding: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  display: block;
  overflow-x: auto;
}

.table th,
.table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.table th {
  color: var(--ink-3);
  font-weight: 600;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card p {
  margin: 0;
}

@media (max-width: 760px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: space-around;
    padding: 4px 4px env(safe-area-inset-bottom);
    border-right: none;
    border-top: 1px solid var(--line);
    z-index: 30;
  }

  .sidebar .brand,
  .nav-link[data-href='#/settings'] {
    display: none;
  }

  .nav-link {
    flex-direction: column;
    gap: 2px;
    padding: 6px 2px;
    font-size: 0.66rem;
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  .nav-link.active {
    background: transparent;
  }

  .main {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }

  .page {
    padding: 18px 16px 32px;
  }

  .review-page,
  .chat-page {
    min-height: calc(100vh - var(--nav-h));
  }

  .only-mobile {
    display: inline-grid !important;
  }

  h1 {
    font-size: 1.45rem;
  }

  .hero-card {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
  }

  .hero-side {
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
  }

  .grid-3 {
    gap: 8px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat-num {
    font-size: 1.35rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .flashcard {
    padding: 16px 18px 20px;
    min-height: 260px;
  }

  .card-tr-big {
    font-size: 1.9rem;
  }

  .card-ru-big {
    font-size: 1.5rem;
  }

  .rate-bar {
    gap: 6px;
  }

  .rate {
    padding: 12px 2px 10px;
  }

  .rate kbd {
    display: none;
  }

  .hint-line {
    display: none;
  }

  .doc {
    padding: 4px 14px 16px;
  }

  .fab-explain {
    bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  }

  .toast {
    bottom: calc(var(--nav-h) + 16px);
  }

  .chat-input {
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }

  .chat-page .page-head {
    flex-direction: column;
  }

  .chat-page .page-head select {
    max-width: 100%;
  }

  .modal {
    max-height: calc(100vh - 24px);
  }
}

.qa-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.note-tr.qa-q {
  font-size: 1.2rem;
  line-height: 1.35;
}

.qa-answer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--green-soft);
  border-radius: 12px;
  padding: 10px 14px;
}

.qa-answer > div[lang] {
  font-weight: 600;
}

.card-qa-big {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.3;
}

.flashcard.revealed .note-tr.qa-q {
  font-size: 1.3rem;
}

.scope-title {
  font-size: 0.9rem;
}

.action-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.action-card .icon {
  color: var(--accent);
}

.action-card p {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

.action-card.accent {
  background: linear-gradient(135deg, var(--accent) 0%, #8f0b22 100%);
  border-color: transparent;
  color: #fff;
}

.action-card.accent .icon,
.action-card.accent p {
  color: #fff;
  opacity: 0.95;
}

.action-card:hover {
  border-color: var(--accent);
}

.qa-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.qa-section {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-3);
  margin: 12px 0 2px;
}

.qa-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
}

.qa-item summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.qa-item summary::-webkit-details-marker {
  display: none;
}

.qa-item[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.qa-item .note-details {
  padding-bottom: 14px;
}

.msg-tools {
  margin-top: 6px;
}

.msg-tools .btn {
  padding: 4px 8px;
  font-size: 0.82rem;
}

.send-btn.recording {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red);
  animation: blink 1.2s infinite;
}

@media (max-width: 760px) {
  .nav-link {
    font-size: 0.6rem;
    padding: 6px 0;
  }

  .nav-link span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.review-head .queue-counts {
  flex-wrap: nowrap;
}

@media (max-width: 760px) {
  .review-head .scope-title {
    max-width: 90px;
    font-size: 0.78rem;
    line-height: 1.15;
  }
}

.badge-rank {
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--mono);
  font-weight: 600;
}
