:root {
  --ink: #172033;
  --muted: #667085;
  --surface: rgba(255, 255, 255, 0.94);
  --line: #e7eaf1;
  --primary: #5b4bdb;
  --primary-dark: #4638bd;
  --accent: #ffb75f;
  --success: #168361;
  --danger: #c54b61;
  --shadow: 0 20px 50px rgba(18, 25, 58, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(132, 112, 255, 0.5), transparent 29rem),
    radial-gradient(circle at 88% 12%, rgba(255, 190, 101, 0.3), transparent 25rem),
    linear-gradient(135deg, #171b43 0%, #27225f 54%, #202c57 100%);
  background-attachment: fixed;
}

.app {
  width: min(100% - 40px, 1020px);
  margin: 0 auto;
  padding: 56px 0 72px;
}

.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 4px 30px;
  color: #fff;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 18px;
  color: #292364;
  font-size: 25px;
  font-weight: 850;
  background: linear-gradient(145deg, #fff7e8, #ffc36d);
  box-shadow: 0 14px 30px rgba(6, 7, 31, 0.28);
  transform: rotate(-5deg);
}

.eyebrow {
  margin: 0 0 6px;
  color: #7667dc;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.hero .eyebrow {
  color: #bdb8ff;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  color: #202a45;
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.hero-copy {
  max-width: 620px;
  margin: 0;
  color: #deddf6;
  font-size: 1rem;
}

.local-badge {
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #e9e7ff;
  font-size: 0.79rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.11);
  white-space: nowrap;
}

.card {
  margin-bottom: 22px;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-form {
  display: grid;
  gap: 15px;
  max-width: 520px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #39435f;
  font-size: .9rem;
  font-weight: 780;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #d8dcec;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.login-form input:focus {
  border-color: #796be2;
  box-shadow: 0 0 0 3px rgba(111, 96, 221, 0.13);
}

.login-form .button {
  justify-self: start;
}

.student-card,
.library-card,
.workspace-card,
.practice-card {
  scroll-margin-top: 20px;
}

.compact-heading {
  align-items: center;
  margin-bottom: 16px;
}

.student-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.student-tab {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #dddaf3;
  border-radius: 999px;
  color: #5143bd;
  font: inherit;
  font-weight: 760;
  cursor: pointer;
  background: #f7f6ff;
}

.student-tab:hover,
.student-tab.active {
  border-color: #6253d7;
  color: #fff;
  background: #6253d7;
}

.student-status {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.student-page-link {
  display: inline-block;
  color: #5143bd;
  font-size: .9rem;
  font-weight: 750;
  text-decoration: none;
}

.student-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.button-small {
  min-height: 38px;
  padding: 7px 12px;
  font-size: .9rem;
}

.student-page-link:hover {
  color: #3729a2;
  text-decoration: underline;
}

.student-account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 13px;
}

.student-account-row .student-status {
  margin: 0;
}

.student-menu-action {
  border: 0;
  color: #5143bd;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.student-menu-action:hover {
  color: #3729a2;
}

.student-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #e2dffc;
  border-radius: 14px;
  background: #faf9ff;
}

.student-menu-action {
  padding: 8px 10px;
  border-radius: 9px;
}

.student-menu-action:hover {
  background: #efedff;
}

.teacher-nav {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  padding: 6px;
  border: 1px solid #e1def5;
  border-radius: 16px;
  background: rgba(255, 255, 255, .68);
}

.teacher-nav-button {
  flex: 1 1 0;
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.teacher-nav-button:hover {
  background: #f1efff;
}

.teacher-nav-button.active {
  color: #fff;
  background: #6253d7;
}

.family-access-card {
  scroll-margin-top: 20px;
}

.family-link-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

.family-link-field input {
  min-width: 0;
  color: #312d55;
  font-size: .95rem;
}

.family-access-actions {
  margin-top: 14px;
}

.view-hidden {
  display: none !important;
}

.family-stats-card {
  scroll-margin-top: 20px;
}

.family-stats-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 16px;
}

.family-stat-summary-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  border: 1px solid #e2e3f0;
  border-radius: 14px;
  background: #fafaff;
}

.family-stat-summary-item span {
  color: #70778d;
  font-size: 0.8rem;
  font-weight: 680;
}

.family-stat-summary-item strong {
  color: #36307d;
  font-size: 1.05rem;
  line-height: 1.3;
}

.family-stats-list {
  display: grid;
  gap: 10px;
}

.family-stat-item {
  padding: 14px;
  border: 1px solid #e5e7f0;
  border-radius: 14px;
  background: #fff;
}

.family-stat-item > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 7px 18px;
}

.family-stat-item strong {
  color: #303a55;
}

.family-stat-item span {
  color: #5a4ec2;
  font-size: 0.9rem;
  font-weight: 760;
}

.family-stat-item p {
  margin: 9px 0 0;
  color: #70778d;
  font-size: 0.88rem;
}

.batch-list {
  display: grid;
  gap: 12px;
}

.batch-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 20px;
  padding: 16px;
  border: 1px solid #e5e7f0;
  border-radius: 15px;
  background: #fbfcff;
}

.batch-item strong {
  color: #303a55;
}

.batch-item strong + span {
  margin-left: 9px;
  color: #737c91;
  font-size: .88rem;
}

.batch-date {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #626b82;
  font-size: .84rem;
  font-weight: 700;
}

.batch-date input {
  padding: 6px 8px;
  border: 1px solid #daddec;
  border-radius: 8px;
  color: #3f4964;
  font: inherit;
  background: #fff;
}

.batch-words {
  grid-column: 1 / -1;
  max-height: 4.2em;
  margin: 2px 0 0;
  overflow: auto;
  color: #5b657d;
  font-size: .91rem;
  line-height: 1.55;
}

.empty-library {
  margin: 0;
  padding: 20px;
  border: 1px dashed #d9ddea;
  border-radius: 14px;
  color: #737c91;
  text-align: center;
  background: #fbfcff;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  font-size: 1.15rem;
  background: linear-gradient(145deg, #7565ed, #4d3fc4);
  box-shadow: 0 8px 18px rgba(91, 75, 219, 0.28);
}

.hint {
  color: var(--muted);
  line-height: 1.55;
}

.input-guide {
  margin-bottom: 4px;
}

.input-guide strong {
  color: #4f42c4;
}

.library-note {
  margin-bottom: 18px;
  font-size: 0.91rem;
}

textarea {
  width: 100%;
  min-height: 216px;
  padding: 18px;
  border: 1px solid #dce1ec;
  border-radius: 16px;
  outline: none;
  color: #27324d;
  font: 500 1rem/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  resize: vertical;
  background: #fbfcff;
  box-shadow: inset 0 1px 2px rgba(39, 50, 77, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea:hover {
  border-color: #c7c3ec;
}

textarea:focus {
  border-color: #796be2;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(111, 96, 221, 0.14);
}

.quiz-settings {
  display: grid;
  grid-template-columns: minmax(150px, 0.38fr) minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
  padding: 20px;
  border: 1px solid #e8e7f4;
  border-radius: 18px;
  background: linear-gradient(120deg, #f8f8ff, #fffaf3);
}

.setting-field {
  min-width: 0;
}

.quiz-settings label {
  display: block;
  color: #39435f;
  font-size: 0.88rem;
  font-weight: 780;
}

.setting-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.balance-value {
  color: #695bd1;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: right;
}

.quiz-settings input[type="number"] {
  width: 100%;
  max-width: 160px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #d8dcec;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  background: #fff;
}

.quiz-settings input[type="number"]:focus {
  border-color: #796be2;
  box-shadow: 0 0 0 3px rgba(111, 96, 221, 0.13);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: #747b90;
  font-size: 0.78rem;
  font-weight: 650;
}

.quiz-settings input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 12px 0 2px;
  border-radius: 999px;
  accent-color: var(--primary);
  cursor: pointer;
}

.family-quiz-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #e8e7f4;
  border-radius: 18px;
  background: linear-gradient(120deg, #f8f8ff, #fffaf3);
}

.family-setting-label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #39435f;
  font-size: 0.88rem;
  font-weight: 780;
}

.family-quiz-settings input,
.family-quiz-settings select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #d8dcec;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  background: #fff;
}

.family-quiz-settings input:focus,
.family-quiz-settings select:focus {
  border-color: #796be2;
  box-shadow: 0 0 0 3px rgba(111, 96, 221, 0.13);
}

.batch-picker {
  grid-column: 1 / -1;
  min-width: 0;
}

.batch-checklist {
  margin: 0;
  padding: 12px;
  border: 1px solid #dfe1ee;
  border-radius: 12px;
}

.batch-checklist legend {
  padding: 0 5px;
  color: #39435f;
  font-size: 0.88rem;
  font-weight: 780;
}

#multipleBatchList {
  display: grid;
  gap: 8px;
}

.batch-check-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e4e5f0;
  border-radius: 10px;
  color: #3d4660;
  font-size: 0.88rem;
  line-height: 1.35;
  background: #fff;
}

.batch-check-option input {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 1px 0 0;
  padding: 0;
  accent-color: var(--primary);
}

.quiz-setup-hint {
  min-height: 1.4em;
  margin: 13px 0 0;
  color: #68708a;
  font-size: 0.88rem;
  line-height: 1.45;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 13px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 780;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

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

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

.button:focus-visible,
.choice-button:focus-visible {
  outline: 3px solid rgba(91, 75, 219, 0.35);
  outline-offset: 3px;
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, #6656df, #4838be);
  box-shadow: 0 9px 18px rgba(77, 61, 193, 0.28);
}

.button-primary:hover {
  background: linear-gradient(135deg, #7565ed, #4e3fc8);
  box-shadow: 0 13px 22px rgba(77, 61, 193, 0.34);
}

.button-secondary {
  border-color: #dad7f7;
  color: #5143bd;
  background: #f3f2ff;
}

.button-secondary:hover {
  border-color: #c3bdf3;
  background: #eae8ff;
}

.button-quiet {
  margin-left: auto;
  color: #8b5260;
  background: transparent;
}

.button-quiet:hover {
  color: #a33d51;
  background: #fff1f3;
}

.storage-status {
  min-height: 24px;
  margin: 18px 0 0;
  padding: 11px 13px;
  border-radius: 12px;
  color: #546079;
  font-size: 0.89rem;
  line-height: 1.45;
  background: #f6f7fb;
}

.quiz-card {
  border-color: rgba(255, 214, 153, 0.65);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(255, 250, 241, 0.96));
}

.quiz-heading {
  align-items: center;
  margin-bottom: 34px;
}

.progress-pill {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #e1dcff;
  border-radius: 999px;
  color: #5a4abd;
  font-size: 0.84rem;
  font-weight: 800;
  background: #f3f1ff;
}

.question-text {
  max-width: 780px;
  margin-bottom: 23px;
  color: #24304c;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  font-weight: 760;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

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

.choice-button {
  min-height: 70px;
  padding: 16px 18px;
  border: 1px solid #e0e4ee;
  border-radius: 15px;
  color: #2f3a54;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 3px 0 #edf0f6;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.choice-button:hover:not(:disabled) {
  border-color: #aaa1ed;
  background: #faf9ff;
  box-shadow: 0 8px 16px rgba(72, 56, 190, 0.1);
  transform: translateY(-2px);
}

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

.feedback {
  min-height: 28px;
  margin: 22px 0 0;
  font-weight: 760;
}

.feedback-correct {
  color: var(--success);
}

.feedback-wrong {
  color: var(--danger);
}

.next-button {
  margin-top: 8px;
}

.hidden {
  display: none;
}

.student-view-body {
  min-height: 100vh;
}

.student-view {
  width: min(100% - 40px, 760px);
  margin: 0 auto;
  padding: 64px 0 80px;
}

.student-view-hero {
  margin-bottom: 25px;
  color: #fff;
}

.student-view-hero h1 {
  margin-bottom: 10px;
}

.student-view-copy {
  margin: 0;
  color: #deddf6;
  font-size: 1.05rem;
}

.student-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 17px;
  border-radius: 15px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.student-selector label {
  color: #49536c;
  font-weight: 700;
}

.student-selector select {
  min-width: 150px;
  margin-left: auto;
  padding: 9px 11px;
  border: 1px solid #d8dcec;
  border-radius: 9px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.student-batch-list {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}

.student-batch-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  padding: clamp(21px, 4vw, 30px);
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.student-batch-heading h2 {
  margin: 0 0 5px;
  font-size: 1.35rem;
}

.student-batch-heading p {
  margin: 0;
  color: #6b748a;
  font-size: .9rem;
}

.student-word-count {
  align-self: start;
  padding: 7px 10px;
  border-radius: 999px;
  color: #5a4abd;
  font-size: .83rem;
  font-weight: 800;
  background: #f1efff;
}

.student-word-list {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.student-word-list li {
  display: grid;
  gap: 2px;
  padding: 12px 13px;
  border: 1px solid #e8eaf1;
  border-radius: 12px;
  background: #fbfcff;
}

.student-word-list strong {
  color: #293552;
}

.student-word-list span {
  color: #68728a;
}

.student-empty-state {
  margin: 0;
  padding: 26px;
  border-radius: 18px;
  color: #fff;
  text-align: center;
  background: rgba(255, 255, 255, .13);
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 28px, 1020px);
    padding: 30px 0 46px;
  }

  .hero {
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 22px;
  }

  .hero > div:nth-child(2) {
    min-width: min(100%, 250px);
  }

  .brand-mark {
    width: 47px;
    height: 47px;
    border-radius: 15px;
  }

  .local-badge {
    margin-left: 0;
  }

  .compact-heading {
    align-items: flex-start;
  }

  .card {
    padding: 23px 19px;
    border-radius: 20px;
  }

  .quiz-settings,
  .family-quiz-settings,
  .family-stats-summary,
  .choices {
    grid-template-columns: 1fr;
  }

  .batch-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .student-view {
    width: min(100% - 28px, 760px);
    padding: 35px 0 50px;
  }

  .student-selector,
  .student-batch-card {
    grid-template-columns: 1fr;
  }

  .student-selector {
    align-items: stretch;
    flex-direction: column;
  }

  .student-selector select {
    width: 100%;
    margin-left: 0;
  }

  .student-word-list {
    grid-template-columns: 1fr;
  }

  .quiz-settings {
    gap: 18px;
  }

  .button-quiet {
    width: 100%;
    margin-left: 0;
  }

  .action-row .button:not(.button-quiet) {
    flex: 1 1 170px;
  }

  .quiz-heading {
    align-items: flex-start;
    margin-bottom: 26px;
  }

  .student-batch-list {
    margin-bottom: 16px;
  }
}

@media (max-width: 480px) {
  .app,
  .student-view {
    width: min(100% - 20px, 1020px);
  }

  .app {
    padding: 22px 0 38px;
  }

  .student-view {
    padding: 27px 0 42px;
  }

  .hero {
    display: grid;
    grid-template-columns: 47px minmax(0, 1fr);
    gap: 12px;
  }

  .hero .local-badge {
    grid-column: 1 / -1;
    width: 100%;
    text-align: center;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .card {
    margin-bottom: 16px;
    padding: 20px 16px;
    border-radius: 18px;
  }

  .section-heading,
  .compact-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }

  .section-icon {
    display: none;
  }

  .compact-heading .button,
  .login-form .button,
  .action-row .button {
    width: 100%;
  }

  .student-tabs {
    gap: 8px;
  }

  .student-tab {
    flex: 1 1 130px;
    min-width: 0;
  }

  .batch-item {
    padding: 14px;
  }

  .batch-date {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .batch-date input {
    width: 100%;
  }

  textarea {
    min-height: 176px;
    padding: 14px;
  }

  .quiz-settings {
    padding: 15px;
  }

  .family-quiz-settings {
    padding: 14px;
  }

  .batch-check-option {
    padding: 10px 9px;
  }

  .setting-label-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .balance-value {
    text-align: left;
  }

  .slider-labels {
    font-size: .7rem;
  }

  .choice-button {
    min-height: 62px;
    padding: 14px;
    font-size: .96rem;
  }

  .student-batch-card {
    gap: 14px;
    padding: 19px 16px;
    border-radius: 18px;
  }

  .student-word-count {
    justify-self: start;
  }
}
