:root {
  color-scheme: light;
  font-family: "Segoe UI", Roboto, sans-serif;
  --background: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --text-primary: #16213e;
  --text-secondary: #3e4c59;
  --text-muted: #6b7a8c;
  --brand: #4c6ef5;
  --brand-strong: #3b5bdb;
  --brand-soft: rgba(76, 110, 245, 0.16);
  --accent: #00b4d8;
  background: var(--background);
  color: var(--text-primary);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  background: radial-gradient(circle at top left, rgba(76, 110, 245, 0.32), transparent 45%),
    radial-gradient(circle at bottom right, rgba(0, 180, 216, 0.28), transparent 50%),
    linear-gradient(160deg, #f3f5ff 0%, #f9fbff 35%, #fdfdfd 100%);
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: clamp(320px, 48vw, 520px);
  height: clamp(320px, 48vw, 520px);
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.55;
  z-index: -2;
  pointer-events: none;
}

body::before {
  top: -40%;
  left: -10%;
  background: linear-gradient(135deg, rgba(76, 110, 245, 0.75), rgba(16, 185, 129, 0.65));
}

body::after {
  bottom: -45%;
  right: -5%;
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.75), rgba(14, 165, 233, 0.55));
}

.container {
  width: min(960px, 100%);
  position: relative;
}

.container::before {
  content: "";
  position: absolute;
  inset: -2rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 32px;
  filter: blur(80px);
  z-index: -1;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  padding: 1rem 1.25rem;
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(76, 110, 245, 0.12);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

.profile-status {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.profile-status span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.card {
  background: var(--surface);
  border-radius: 24px;
  padding: 2.25rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:not(.hidden):hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 70px rgba(16, 24, 40, 0.14);
}

h1,
h2,
h3 {
  margin: 0 0 1rem;
  font-weight: 650;
  color: var(--text-primary);
}

.subtitle {
  margin-top: -0.5rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1.5rem 0;
  font-weight: 500;
}

.field.compact {
  margin: 0;
}

select {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(76, 110, 245, 0.24);
  font-size: 1rem;
  background: var(--surface-strong);
  color: var(--text-primary);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(76, 110, 245, 0.18);
}

.actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.info-text {
  color: var(--text-muted);
  margin-top: 1rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease,
    color 0.15s ease;
  will-change: transform;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.primary {
  background: linear-gradient(135deg, var(--brand) 0%, #5f6ef7 100%);
  color: #fff;
  box-shadow: 0 14px 30px rgba(76, 110, 245, 0.28);
}

.secondary {
  background: rgba(76, 110, 245, 0.12);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px rgba(76, 110, 245, 0.18);
}

.primary:hover {
  box-shadow: 0 18px 40px rgba(76, 110, 245, 0.28);
}

.secondary:hover {
  background: rgba(76, 110, 245, 0.18);
}

.primary:focus-visible,
.secondary:focus-visible,
.text-button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(76, 110, 245, 0.18);
}

.success {
  color: #3ba271;
  min-height: 1.2rem;
}

.text-button {
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  position: relative;
  font-weight: 600;
}

.text-button::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
  border-radius: 999px;
  opacity: 0.7;
}

.text-button:hover::after {
  transform: scaleX(1);
}

.error {
  color: #d64545;
  min-height: 1.2rem;
}

.exam-header,
.exam-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid rgba(76, 110, 245, 0.08);
  padding-top: 1.5rem;
}

.exam-header {
  border-top: none;
  padding-top: 0;
  padding-bottom: 1rem;
}

#questionsContainer {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 2rem 0;
}

.profile-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.profile-card {
  border: 1px solid rgba(76, 110, 245, 0.16);
  border-radius: 18px;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-card button {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.profile-card.selected {
  border-color: rgba(76, 110, 245, 0.9);
  box-shadow: 0 18px 36px rgba(76, 110, 245, 0.26);
}

.profile-card h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.profile-card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.4;
}

.question-card {
  border: 1px solid #e4e9f2;
  border-radius: 12px;
  padding: 1.5rem;
  background: #fdfefe;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
}

.question-card.correct {
  border-color: #3ba271;
  background: #f3fcf7;
}

.question-card.incorrect {
  border-color: #d64545;
  background: #fff5f5;
}

.question-title {
  font-weight: 600;
}

.question-translation {
  margin: -0.3rem 0 0;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.options label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.options label:hover {
  background: #f0f4ff;
}

.options label.option-correct {
  background: #e6f7ed;
  border-color: #3ba271;
  color: #214c36;
}

.options label.option-wrong {
  background: #fdecea;
  border-color: #d64545;
  color: #5b1f1f;
}

.option-letter {
  font-weight: 600;
  color: #52606d;
}

.question-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.question-actions button {
  background: #eef2fa;
  color: #1f2933;
  padding: 0.5rem 1.1rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 99;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  position: relative;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  font-size: 1.5rem;
  background: transparent;
  color: var(--text-muted);
  padding: 0.2rem;
}

.modal p {
  margin: 0.8rem 0 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal .subtitle {
  margin-top: 0;
}

.grammar-section {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: 12px;
  background: #f5f8ff;
  border: 1px solid rgba(31, 122, 236, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.grammar-section::before {
  content: "✨";
  font-size: 1.1rem;
}

.grammar-trigger {
  align-self: flex-start;
  background: linear-gradient(135deg, #1f7aec, #4f46e5);
  color: #fff;
  box-shadow: 0 12px 26px rgba(79, 70, 229, 0.28);
  padding: 0.55rem 1.6rem;
}

.grammar-trigger:hover,
.grammar-trigger:focus {
  background: linear-gradient(135deg, #155bb5, #4338ca);
}

.grammar-modal-content {
  max-width: 720px;
  width: min(720px, 95%);
}

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

.grammar-modal-subtitle {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6c7a91;
  font-size: 0.78rem;
  font-weight: 700;
}

#grammarModalTitle {
  margin: 0.25rem 0 0;
}

.grammar-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.grammar-lesson-wrapper {
  background: linear-gradient(135deg, rgba(31, 122, 236, 0.14), rgba(79, 70, 229, 0.14));
  border-radius: 18px;
  padding: 1.25rem 1.4rem;
  border: 1px solid rgba(31, 122, 236, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.grammar-lesson-body {
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
  color: #1f2933;
}

.grammar-lesson-body p {
  margin: 0.7rem 0;
  line-height: 1.6;
  color: #213047;
}

.grammar-lesson-body p:first-child {
  margin-top: 0;
}

.grammar-lesson-body ul,
.grammar-lesson-body ol {
  padding-left: 1.2rem;
  margin: 0.6rem 0;
  color: #1f2933;
}

.grammar-lesson-body li {
  margin: 0.35rem 0;
}

.grammar-lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.grammar-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  background: rgba(31, 122, 236, 0.15);
  color: #155bb5;
  font-weight: 600;
  font-size: 0.85rem;
}

.grammar-badge::before {
  content: "✔";
  font-size: 0.85rem;
}

.grammar-badge.error {
  background: rgba(220, 38, 38, 0.16);
  color: #b91c1c;
}

.grammar-badge.error::before {
  content: "⚠";
  color: #dc2626;
}

.grammar-badge.new {
  background: rgba(16, 185, 129, 0.18);
  color: #047857;
}

.grammar-badge.new::before {
  content: "★";
  color: #059669;
}

.grammar-lesson-updated {
  color: #3e4c59;
  font-size: 0.9rem;
}

.grammar-lesson-prompt {
  margin-bottom: 0.9rem;
  padding: 0.8rem 1rem;
  background: rgba(244, 247, 255, 0.95);
  border-radius: 14px;
  border-left: 4px solid rgba(79, 70, 229, 0.65);
  color: #213047;
}

.grammar-lesson-prompt strong {
  color: #4338ca;
}

.grammar-lesson-footnote {
  margin-top: 0.9rem;
  color: #52606d;
  font-size: 0.92rem;
}

.grammar-error {
  color: #d64545;
  font-weight: 600;
  margin: 0;
}

.grammar-modal-body::-webkit-scrollbar {
  width: 0.5rem;
}

.grammar-modal-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.08);
  border-radius: 12px;
}

.grammar-modal-body::-webkit-scrollbar-thumb {
  background: rgba(31, 122, 236, 0.45);
  border-radius: 12px;
}

.hidden {
  display: none !important;
}

.modal.hidden {
  display: none !important;
}

#resultMessage {
  font-weight: 600;
  color: var(--brand-strong);
}

.admin-content {
  max-width: 640px;
  width: 100%;
}

.admin-form input,
.admin-form textarea {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(76, 110, 245, 0.2);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface-strong);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.admin-form textarea {
  resize: vertical;
}

.admin-form input:focus-visible,
.admin-form textarea:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(76, 110, 245, 0.18);
}

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

.admin-history-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.admin-history-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-section + .admin-section {
  margin-top: 1.5rem;
}

.admin-profile-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-profile-row {
  border: 1px solid rgba(76, 110, 245, 0.16);
  border-radius: 16px;
  padding: 0.9rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.admin-profile-row .details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.admin-profile-row .details span {
  font-weight: 600;
}

.admin-profile-row .details small {
  color: #52606d;
}

.admin-profile-row .row-actions {
  display: flex;
  gap: 0.5rem;
}

.admin-profile-row .row-actions button {
  padding: 0.45rem 1.1rem;
  background: rgba(76, 110, 245, 0.12);
  color: var(--brand-strong);
}

.admin-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.admin-history-row {
  border: 1px solid rgba(76, 110, 245, 0.16);
  border-radius: 16px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.92);
  align-items: center;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.admin-history-row .details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.admin-history-row .details span {
  font-weight: 600;
}

.admin-history-row .details small {
  color: #52606d;
}

.admin-history-row .meta {
  text-align: right;
  color: #52606d;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

@media (max-width: 960px) {
  body {
    padding: 3rem 1.25rem;
  }

  .container::before {
    inset: -1.25rem;
  }

  .card {
    padding: 2rem;
  }
}

@media (max-width: 820px) {
  .admin-history-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-history-row .meta {
    text-align: left;
  }
}

@media (max-width: 640px) {
  body {
    padding: 2.5rem 1rem;
    align-items: flex-start;
  }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
  }

  .container::before {
    display: none;
  }

  .card {
    padding: 1.65rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .actions {
    flex-direction: column;
  }

  .question-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .top-bar {
    gap: 0.65rem;
  }

  .admin-profile-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-profile-row .row-actions {
    align-self: stretch;
    justify-content: flex-start;
  }

  .admin-history-controls {
    width: 100%;
  }
}

