:root {
  --bg-top: #f7efe2;
  --bg-bottom: #dbe8f2;
  --panel: rgba(255, 251, 245, 0.84);
  --panel-strong: rgba(255, 251, 245, 0.96);
  --text: #17324a;
  --muted: #55697c;
  --accent: #cb5a2d;
  --accent-dark: #9f4220;
  --outline: rgba(23, 50, 74, 0.12);
  --shadow: 0 24px 70px rgba(23, 50, 74, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(203, 90, 45, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(66, 116, 161, 0.18), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  filter: blur(22px);
  pointer-events: none;
  opacity: 0.4;
}

body::before {
  top: -6rem;
  right: -4rem;
  background: rgba(203, 90, 45, 0.3);
}

body::after {
  bottom: -9rem;
  left: -5rem;
  background: rgba(66, 116, 161, 0.22);
}

.app-shell {
  width: min(980px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.profile-shell {
  margin-bottom: 1rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-block {
  min-width: 0;
  margin-top: 1.5rem;
}

.auth-actions,
.profile-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.auth-actions {
  margin-top: 1rem;
}

.profile-input {
  appearance: none;
  border: 1px solid rgba(23, 50, 74, 0.12);
  background: rgba(255, 251, 245, 0.92);
  color: var(--text);
  border-radius: 999px;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 600;
  min-width: 12rem;
  flex: 1 1 12rem;
}

.profile-list {
  display: grid;
  gap: 0.8rem;
}

.profile-list-item {
  appearance: none;
  border: 1px solid rgba(23, 50, 74, 0.08);
  background: rgba(255, 251, 245, 0.88);
  border-radius: 20px;
  padding: 1rem 1.1rem;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.profile-list-item:hover {
  transform: translateY(-1px);
  border-color: rgba(203, 90, 45, 0.3);
  box-shadow: 0 14px 32px rgba(23, 50, 74, 0.08);
  background: rgba(255, 251, 245, 0.96);
}

.profile-list-name,
.profile-list-meta {
  display: block;
}

.profile-list-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.profile-list-meta {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
  padding-right: 2rem;
}

.profile-delete-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 999px;
}

.profile-delete-button:hover {
  color: var(--accent-dark);
  background: rgba(203, 90, 45, 0.12);
}

.profile-empty {
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(255, 251, 245, 0.7);
  border: 1px dashed rgba(23, 50, 74, 0.16);
  color: var(--muted);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 50, 74, 0.34);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.4rem;
  border-radius: 24px;
  background: rgba(255, 251, 245, 0.98);
  border: 1px solid rgba(23, 50, 74, 0.08);
  box-shadow: 0 28px 80px rgba(23, 50, 74, 0.22);
}

.modal-header,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.modal-header {
  margin-bottom: 1rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1;
}

.modal-actions {
  margin-top: 1rem;
  justify-content: flex-end;
}

.hero {
  margin-bottom: 1.75rem;
}

.session-box {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.session-box .button {
  padding: 0.72rem 1rem;
  font-size: 0.95rem;
}

.eyebrow,
.label {
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: inherit;
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  line-height: 0.95;
}

.subtitle {
  margin: 0.85rem 0 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.selector-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1.15rem;
  flex-wrap: wrap;
}

.selector-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.lesson-select {
  appearance: none;
  border: 1px solid rgba(23, 50, 74, 0.12);
  background: rgba(255, 251, 245, 0.92);
  color: var(--text);
  border-radius: 999px;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 600;
  min-width: min(28rem, 100%);
}

.is-hidden {
  display: none;
}

.mode-bar {
  margin-bottom: 1rem;
}

.mode-options {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.slide {
  background: var(--panel);
  border: 1px solid var(--outline);
  border-radius: 30px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

#lesson-view {
  min-height: 36rem;
  display: flex;
  flex-direction: column;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.lesson-filter-row {
  justify-content: space-between;
  align-items: center;
}

.lesson-filter-shell {
  position: relative;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  width: 2.4rem;
  height: 2.4rem;
  font: inherit;
  font-weight: 700;
  background: rgba(23, 50, 74, 0.1);
  color: var(--text);
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.icon-button.is-selected {
  background: rgba(203, 90, 45, 0.18);
  color: var(--accent-dark);
  transform: translateY(-1px);
}

.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.card {
  background: var(--panel-strong);
  border-radius: 24px;
  padding: 1.4rem;
  border: 1px solid rgba(23, 50, 74, 0.08);
}

#lesson-view .lesson-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  min-height: 28rem;
}

.lesson-card-visual {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 0.92;
  letter-spacing: 0.12em;
  white-space: pre-line;
  text-align: center;
  opacity: 0.25;
  filter: saturate(0.9) blur(0.2px);
  transform: translateY(0.25rem);
  z-index: 0;
}

.lesson-card-visual.lesson-card-visual-compact {
  font-size: clamp(3.2rem, 9.5vw, 5.8rem);
  letter-spacing: 0.08em;
}

.lesson-card-visual.lesson-card-visual-wide {
  font-size: clamp(3rem, 8.8vw, 5.2rem);
  letter-spacing: 0.06em;
}

.lesson-card-visual::before {
  content: "";
  position: absolute;
  width: min(26rem, 72%);
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(203, 90, 45, 0.12), transparent 68%);
  filter: blur(6px);
  z-index: -1;
}

#lesson-view .lesson-card .word-panel,
#lesson-view .lesson-card .sentence-panel {
  position: relative;
  z-index: 1;
}

#lesson-view .lesson-card .word-panel,
#lesson-view .lesson-card .sentence-panel,
#lesson-view .lesson-card .lesson-card-visual {
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

#lesson-view .lesson-card.is-transitioning .word-panel,
#lesson-view .lesson-card.is-transitioning .sentence-panel,
#lesson-view .lesson-card.is-transitioning .lesson-card-visual {
  opacity: 0;
  transform: translateY(0.4rem);
}

.content-panel {
  padding: 0.8rem;
  border-radius: 18px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.content-panel.is-active {
  background: rgba(203, 90, 45, 0.12);
  border-color: rgba(203, 90, 45, 0.3);
  box-shadow: inset 0 0 0 1px rgba(203, 90, 45, 0.12);
  transform: translateY(-1px);
}

.content-panel.is-active .label {
  color: var(--accent-dark);
}

.content-panel:focus-visible {
  outline: 2px solid rgba(23, 50, 74, 0.45);
  outline-offset: 3px;
}

.word-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(23, 50, 74, 0.08);
  height: 100%;
  align-items: stretch;
}

.word-panel h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.95;
}

.word-panel .label {
  display: none;
}

.sentence-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding-top: 1rem;
  height: 100%;
  align-items: stretch;
}

.sentence-block .label {
  display: none;
}

.sentence {
  margin: 0;
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  line-height: 1.45;
  max-width: 22rem;
}

.lesson-card-toolbar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
}

.menu-shell {
  position: relative;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  min-width: min(24rem, calc(100vw - 3rem));
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid rgba(23, 50, 74, 0.12);
  background: rgba(255, 251, 245, 0.98);
  box-shadow: 0 20px 50px rgba(23, 50, 74, 0.18);
  display: grid;
  gap: 0.9rem;
  z-index: 5;
}

.settings-menu.is-hidden {
  display: none;
}

.settings-group {
  display: grid;
  gap: 0.45rem;
}

@media (max-width: 720px) {
  .lesson-card-visual {
    font-size: clamp(3.2rem, 16vw, 5.8rem);
    opacity: 0.2;
  }
}

.quiz-prompt {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(23, 50, 74, 0.08);
  align-items: center;
}

.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.quiz-overlay.is-hidden {
  display: none;
}

.quiz-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 50, 74, 0.34);
  backdrop-filter: blur(6px);
}

.quiz-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(46rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quiz-progress-row {
  margin-bottom: 0;
  padding: 0 0.25rem;
}

.quiz-card {
  overflow: auto;
}

.quiz-word-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-family: inherit;
  font-weight: 800;
  line-height: 0.95;
  text-align: center;
  color: var(--text);
  cursor: pointer;
}

.quiz-word-button:disabled {
  cursor: default;
  opacity: 0.6;
}

.quiz-word-button:hover:not(:disabled) {
  color: var(--accent-dark);
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.quiz-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: stretch;
}

.quiz-option {
  text-align: center;
  min-height: 4.25rem;
  border: 1px solid rgba(23, 50, 74, 0.08);
}

.quiz-option-audio {
  appearance: none;
  border: 1px solid rgba(23, 50, 74, 0.12);
  border-radius: 18px;
  width: 3rem;
  min-height: 4.25rem;
  background: rgba(23, 50, 74, 0.08);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 1.05rem;
  transition:
    transform 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

.quiz-option-audio:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(23, 50, 74, 0.14);
}

.quiz-option-audio:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.quiz-option.is-correct {
  background: rgba(76, 140, 82, 0.18);
  color: #18381c;
}

.quiz-option.is-wrong {
  background: rgba(203, 90, 45, 0.18);
  color: #5d2916;
}

.quiz-result {
  min-height: 1.75rem;
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.quiz-summary {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(23, 50, 74, 0.08);
}

.quiz-feedback {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-weight: 600;
}

.quiz-progress-dots {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  padding: 0 0.25rem;
}

.quiz-progress-dot {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  border: 1px solid rgba(23, 50, 74, 0.16);
  background: rgba(255, 251, 245, 0.82);
  color: var(--muted);
}

.quiz-progress-dot.is-correct {
  background: rgba(92, 156, 104, 0.18);
  border-color: rgba(92, 156, 104, 0.34);
  color: #1e4d28;
}

.quiz-progress-dot.is-wrong {
  background: rgba(203, 90, 45, 0.18);
  border-color: rgba(203, 90, 45, 0.34);
  color: #7a2f15;
}

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

.lesson-card {
  text-align: center;
  min-height: 6rem;
  border: 1px solid rgba(23, 50, 74, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.08rem;
  line-height: 1.25;
}

#lessons-home .lesson-filter-button {
  padding: 0.62rem 1rem;
  font-size: 0.92rem;
  font-weight: 700;
  background: rgba(23, 50, 74, 0.1);
  border: 1px solid rgba(23, 50, 74, 0.12);
  min-width: 7.5rem;
}

#lessons-home .lesson-filter-button::after {
  content: "▾";
  margin-left: 0.6rem;
  font-size: 0.8em;
}

#lessons-home .lesson-filter-button.is-new {
  background: rgba(23, 50, 74, 0.08);
}

#lessons-home .lesson-filter-button.is-started {
  background: rgba(93, 145, 201, 0.2);
  border-color: rgba(93, 145, 201, 0.34);
}

#lessons-home .lesson-filter-button.is-completed {
  background: rgba(92, 156, 104, 0.18);
  border-color: rgba(92, 156, 104, 0.32);
}

.lesson-filter-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  min-width: 11rem;
  padding: 0.45rem;
  border-radius: 18px;
  border: 1px solid rgba(23, 50, 74, 0.12);
  background: rgba(255, 251, 245, 0.98);
  box-shadow: 0 20px 50px rgba(23, 50, 74, 0.18);
  display: grid;
  gap: 0.35rem;
  z-index: 6;
}

.lesson-filter-menu.is-hidden {
  display: none;
}

#lessons-home .lesson-filter-option {
  width: 100%;
  text-align: center;
  padding: 0.72rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 700;
  background: rgba(255, 251, 245, 0.98);
  border: 1px solid transparent;
}

#lessons-home .lesson-filter-option-new {
  background: rgba(23, 50, 74, 0.08);
  border-color: rgba(23, 50, 74, 0.12);
}

#lessons-home .lesson-filter-option-started {
  background: rgba(93, 145, 201, 0.2);
  border-color: rgba(93, 145, 201, 0.34);
}

#lessons-home .lesson-filter-option-completed {
  background: rgba(92, 156, 104, 0.18);
  border-color: rgba(92, 156, 104, 0.32);
}

#lessons-home .lesson-filter-option.is-selected {
  box-shadow: inset 0 0 0 2px rgba(23, 50, 74, 0.35);
}

.lesson-card.is-started {
  background: rgba(93, 145, 201, 0.16);
  border-color: rgba(93, 145, 201, 0.3);
}

.lesson-card.is-started:hover:not(:disabled) {
  background: rgba(93, 145, 201, 0.22);
}

.lesson-card.is-mastered {
  background: rgba(92, 156, 104, 0.14);
  border-color: rgba(92, 156, 104, 0.28);
}

.lesson-card.is-mastered:hover:not(:disabled) {
  background: rgba(92, 156, 104, 0.2);
}

.quiz-summary h3 {
  margin: 0;
  font-size: 1.4rem;
}

.history-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(23, 50, 74, 0.08);
}

.history-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.history-list li + li {
  margin-top: 0.4rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

.speed-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.speed-options {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.35rem;
  font: inherit;
  font-weight: 700;
  background: rgba(23, 50, 74, 0.1);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(23, 50, 74, 0.16);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-primary {
  background: var(--accent);
  color: #fff8f2;
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button-speed {
  padding: 0.72rem 1.05rem;
  background: rgba(23, 50, 74, 0.08);
}

.button-speed.is-selected {
  background: rgba(23, 50, 74, 0.88);
  color: #fff8f2;
}

.button-secondary {
  align-self: flex-start;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 1rem, 980px);
    padding-top: 1.25rem;
  }

  .slide,
  .card,
  .session-box {
    border-radius: 22px;
  }

  .word-panel,
  .sentence-panel,
  .quiz-options,
  .lesson-list {
    grid-template-columns: 1fr;
  }

  #lesson-view {
    min-height: auto;
  }

  #lesson-view .lesson-card {
    flex: initial;
    display: block;
    min-height: auto;
  }

  .content-panel {
    min-height: 8.5rem;
  }

  .app-header {
    flex-direction: column;
  }

  .session-box {
    width: 100%;
  }

  .lesson-card-toolbar {
    flex-direction: column;
    align-items: flex-end;
  }

  .lesson-card-toolbar .card-actions {
    justify-content: flex-end;
  }

  .settings-menu {
    left: 0;
    right: auto;
    min-width: min(22rem, calc(100vw - 3rem));
  }

  .sentence-block {
    min-height: auto;
  }

  .progress-row {
    flex-direction: column;
    gap: 0.35rem;
  }
}
