
:root {
  --bg: #f5fbff;
  --card: #ffffff;
  --text: #13202d;
  --muted: #627386;
  --accent: #27c7c0;
  --accent-dark: #116d9b;
  --accent-text: #081b22;
  --accent-rgb: 39, 199, 192;
  --accent-dark-rgb: 17, 109, 155;
  --support: #ffbd2f;
  --support-dark: #b56f00;
  --support-rgb: 255, 189, 47;
  --border: rgba(19, 32, 45, 0.12);
  --shadow: 0 18px 45px rgba(17, 109, 155, 0.13);
  --reader-size: 1.08rem;
}

body.dark {
  --bg: #171411;
  --card: #24201c;
  --text: #f8efe4;
  --muted: #c7b7a3;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(var(--accent-rgb), 0.2), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(var(--support-rgb), 0.15), transparent 26rem),
    var(--bg);
  color: var(--text);
}

body.font-large { --reader-size: 1.22rem; }
body.font-xlarge { --reader-size: 1.38rem; }

#app {
  max-width: 780px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px;
}

body.has-mobile-nav #app {
  padding-bottom: calc(94px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 20px;
}

.topbar > div:first-child {
  min-width: 0;
}

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

h1 {
  margin-bottom: 0;
  white-space: nowrap;
  font-size: 2rem;
  line-height: 1.22;
}
h2 { font-size: 1.65rem; }
h3 { font-size: 1.1rem; }

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

.eyebrow {
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  font-size: 0.76rem;
  margin-bottom: 5px;
}

.top-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.top-actions #settingsBtn:not(.hidden),
.top-actions #logoutBtn:not(.hidden) {
  display: grid;
}

.reader-card, .article-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.icon-btn, .text-btn, .back-btn, .primary-btn, .secondary-btn, .audio-btn, .chip {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.icon-btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-nav-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.mobile-bottom-nav:not(.hidden) {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  max-width: 780px;
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow: 0 16px 38px rgba(36, 26, 16, 0.18);
  backdrop-filter: blur(14px);
}

.mobile-nav-btn {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  padding: 8px 4px 7px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.mobile-nav-btn.active {
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--text);
}

.mobile-nav-icon {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  font-size: 1.12rem;
  line-height: 1;
}

.mobile-nav-label {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.72rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 18px;
}

.filters {
  min-width: 0;
}

.filter-select-wrap {
  flex: 1 1 180px;
}

.filter-select-label {
  display: grid;
  gap: 5px;
}

.filter-select-label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.filter-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 42px 10px 14px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 999px;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent-dark) 50%) calc(100% - 20px) 19px / 7px 7px no-repeat,
    linear-gradient(135deg, var(--accent-dark) 50%, transparent 50%) calc(100% - 15px) 19px / 7px 7px no-repeat,
    rgba(var(--accent-rgb), 0.14);
  color: var(--text);
  font: inherit;
  font-weight: 850;
  appearance: none;
}

.filter-select:focus {
  outline: 3px solid rgba(var(--accent-rgb), 0.28);
  outline-offset: 2px;
}

.chip {
  white-space: nowrap;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--text);
}

.chip.active {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
}

.more-chip {
  background: transparent;
  color: var(--accent-dark);
  font-weight: 850;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clicked-review {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.clicked-review.hidden {
  display: none;
}

.clicked-review .muted {
  margin: 0;
}

.clicked-review-compact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.clicked-review-compact .practice-heading {
  display: contents;
}

.clicked-review-compact .muted {
  grid-column: 1 / -1;
}

.clicked-review-compact .quiz-prompt,
.clicked-review-compact .quiz-options,
.clicked-review-compact .practice-feedback {
  display: none;
}

.review-dialog-card {
  width: min(100%, 460px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  box-shadow: var(--shadow);
}

.review-dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-btn {
  background: transparent;
  color: var(--accent-dark);
  font-weight: 800;
}

.filter-bar {
  align-items: end;
}

.article-language-filters {
  min-width: 260px;
}

.segmented-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(127, 127, 127, 0.06);
}

.segmented-filter.compact {
  margin: 4px 0 14px;
}

.segmented-filter-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0 8px;
  white-space: nowrap;
}

.segmented-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  font-weight: 900;
}

.segmented-filter-btn.active {
  color: var(--accent-text);
  background: var(--accent);
}

.segmented-filter-count {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.18);
  font-size: 0.78rem;
}

.segmented-filter-btn.active .segmented-filter-count {
  background: rgba(255, 255, 255, 0.22);
}

.article-variant-switch {
  margin: -4px 0 12px;
}

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

.article-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  text-align: left;
  width: 100%;
  color: var(--text);
  padding: 18px;
}

.article-card-thumb {
  width: 104px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.08);
}

.article-card-body {
  min-width: 0;
}

.article-card h4 {
  font-size: 1.18rem;
  margin: 0 0 8px;
}

.article-card p {
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.badge {
  font-size: 0.78rem;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.12);
  padding: 5px 9px;
}

.start-badge {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
}

.hidden { display: none; }

.profile-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 800;
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.back-btn {
  background: transparent;
  color: var(--text);
  font-weight: 800;
  padding: 8px 2px 16px;
}

.reader-card {
  padding: 22px;
}

.article-image-wrap {
  margin: 18px 0 22px;
}

.article-image-wrap picture {
  display: block;
}

.article-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
}

.article-text {
  font-size: var(--reader-size);
  line-height: 1.75;
}

.article-text p {
  margin-bottom: 1.1em;
}

.task-progress {
  margin: 16px 0 4px;
}

.task-progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(127, 127, 127, 0.07);
  font-weight: 850;
}

.task-progress-line.complete {
  border-color: rgba(62, 139, 91, 0.52);
  background: rgba(62, 139, 91, 0.16);
}

.listen-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 20px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(127, 127, 127, 0.07);
}

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

.audio-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--text);
  color: var(--card);
  font-weight: 900;
  line-height: 1;
}

.secondary-btn {
  padding: 11px 14px;
  border-radius: 15px;
  background: var(--text);
  color: var(--card);
  font-weight: 900;
}

.secondary-btn.quiet {
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--text);
}

#loginView .secondary-btn {
  width: 100%;
  margin-top: 10px;
}

.auth-email-row {
  margin-top: 14px;
}

.legacy-login-row {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.secondary-btn.danger {
  background: rgba(180, 35, 24, 0.12);
  color: #b42318;
  border: 1px solid rgba(180, 35, 24, 0.25);
}

.listen-status {
  min-height: 1.4em;
  margin-bottom: 0;
}

.reading-sentence {
  border-radius: 8px;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.reading-sentence.active {
  background: rgba(var(--accent-rgb), 0.22);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

.inline-word {
  position: relative;
  display: inline;
  border: 0;
  border-radius: 6px;
  padding: 1px 3px 2px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  white-space: normal;
  text-align: inherit;
  word-break: normal;
  overflow-wrap: normal;
  text-decoration: underline;
  text-decoration-color: var(--accent-dark);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  cursor: pointer;
  touch-action: manipulation;
}

.inline-word.active {
  background: rgba(var(--accent-rgb), 0.18);
}

.reader-word {
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
}

.reader-word:hover,
.reader-word.translation-anchor,
.reading-sentence.translation-anchor {
  background: rgba(var(--accent-rgb), 0.12);
}

.inline-translation-tooltip {
  position: fixed;
  z-index: 40;
  width: max-content;
  max-width: min(18rem, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
  text-align: center;
  overflow-wrap: break-word;
  pointer-events: auto;
}

.inline-translation-tooltip.hidden {
  display: none;
}

.inline-translation-tooltip::before {
  content: "";
  position: absolute;
  left: var(--arrow-left, 50%);
  top: 100%;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.inline-translation-tooltip.below::before {
  top: auto;
  bottom: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.translation-actions {
  display: flex;
  gap: 7px;
}

.translation-actions button {
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
}

.translation-actions button:hover {
  background: rgba(var(--accent-rgb), 0.22);
}

.translation-result {
  display: grid;
  gap: 5px;
  min-width: 11rem;
  max-width: 22rem;
  text-align: left;
}

.translation-result strong {
  color: var(--muted);
  font-size: 0.78rem;
}

.translation-kind {
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.translation-loading,
.translation-error {
  display: block;
  max-width: 18rem;
}

.translation-error {
  color: var(--danger, #b42318);
}

.panel {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 14px;
}

.panel li {
  margin: 10px 0;
  line-height: 1.45;
}

.question-text {
  margin-bottom: 8px;
  font-weight: 750;
}

.answer-input {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.article-editor {
  margin-top: 18px;
}

.editor-bottom-back {
  margin-top: 18px;
  padding-bottom: 0;
}

.editor-helper {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(127, 127, 127, 0.06);
}

.editor-step {
  display: grid;
  gap: 10px;
}

.editor-step.hidden {
  display: none;
}

.category-translations {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.52);
}

.category-translations.hidden {
  display: none;
}

.category-translations .muted {
  margin: 0 0 10px;
}

.category-translation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.field-row.compact {
  gap: 5px;
  margin: 0;
  font-size: 0.8rem;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.editor-textarea.compact {
  min-height: 76px;
}

.editor-textarea.tall {
  min-height: 220px;
}

#articlePromptInput {
  min-height: 150px;
}

#articleRequiredWordsInput {
  min-height: 110px;
}

#articleTextInput {
  min-height: 340px;
}

.article-text-editor {
  position: relative;
  width: 100%;
  min-height: 340px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  overflow: hidden;
}

.article-text-editor #articleTextInput {
  position: relative;
  z-index: 2;
  min-height: 340px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  resize: vertical;
  scrollbar-gutter: stable;
}

.article-text-editor #articleTextInput::selection {
  background: rgba(var(--accent-rgb), 0.28);
}

.inline-highlight-preview {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  padding: 12px;
  box-sizing: border-box;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  right: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  scrollbar-width: none;
}

.inline-highlight-preview::-webkit-scrollbar {
  display: none;
}

.editor-inline-hit {
  border-radius: 6px;
  background: rgba(var(--accent-rgb), 0.24);
  box-shadow: inset 0 -2px 0 rgba(var(--accent-dark-rgb), 0.55);
}

.inline-selection-btn {
  position: absolute;
  z-index: 4;
  min-height: 38px;
  max-width: calc(100% - 16px);
  padding: 9px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 10px 24px rgba(var(--accent-dark-rgb), 0.24);
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.true-false-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 13px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.choice-btn.selected {
  background: var(--accent);
  color: var(--accent-text);
}

.true-false-item.task-complete {
  border-radius: 16px;
  padding: 10px;
  background: rgba(62, 139, 91, 0.1);
}

.practice-panel {
  display: grid;
  gap: 12px;
  scroll-margin-top: 72px;
}

.practice-tabs {
  display: none;
}

.practice-tab {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.practice-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.practice-heading h3,
.practice-heading .eyebrow {
  margin-bottom: 0;
}

.sentence-target,
.word-bank,
.match-board {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sentence-target {
  min-height: 54px;
  align-items: center;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: rgba(127, 127, 127, 0.06);
}

.word-chip,
.match-card {
  border: 1px solid var(--border);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  background: var(--card);
}

.word-chip {
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 800;
}

.onboarding-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 12px 0 18px;
  padding: 14px;
  border: 1px solid rgba(var(--support-rgb), 0.52);
  border-radius: 8px;
  background: rgba(var(--support-rgb), 0.18);
}

.onboarding-panel.hidden {
  display: none;
}

.onboarding-panel.compact {
  align-items: center;
  margin-top: 16px;
}

.onboarding-panel h3,
.onboarding-panel p {
  margin-bottom: 4px;
}

.inline-word.onboarding-focus {
  background: rgba(var(--accent-rgb), 0.2);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

.word-chip.selected {
  background: var(--accent);
  color: var(--accent-text);
}

.vocab-base {
  color: var(--muted);
  font-weight: 700;
}

.match-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.match-card {
  min-height: 54px;
  border-radius: 16px;
  padding: 10px;
  font-weight: 850;
}

.match-card.selected {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: var(--accent-dark);
}

.match-card.matched {
  opacity: 0.58;
  background: rgba(62, 139, 91, 0.16);
  text-decoration: line-through;
}

.practice-feedback {
  min-height: 1.3em;
  margin: 0;
  color: var(--accent-dark);
  font-weight: 850;
}

.quiz-prompt.compact,
.cloze-sentence,
.mistake-sentence {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.55;
  font-weight: 850;
}

.word-search-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-search-hints li {
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(127, 127, 127, 0.1);
  font-weight: 800;
}

.word-search-hints li.found {
  background: rgba(62, 139, 91, 0.16);
  text-decoration: line-through;
}

.word-search-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  max-width: 520px;
}

.letter-cell {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 900;
}

.letter-cell.selected {
  background: var(--accent);
  color: var(--accent-text);
}

.letter-cell.found {
  border-color: rgba(62, 139, 91, 0.6);
  background: rgba(62, 139, 91, 0.2);
  color: var(--text);
}

.letter-cell.found.selected {
  background: var(--accent);
}

.field-row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  color: var(--muted);
  font-weight: 800;
}

.field-row.hidden {
  display: none;
}

.field-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 13px 14px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field-row select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

#articleEditorSelect {
  min-width: 0;
}

.form-error {
  min-height: 1.3em;
  margin: 4px 0 0;
  color: #b42318;
  font-weight: 800;
}

.section-title.compact {
  margin-top: 0;
  margin-bottom: 8px;
}

.assignment-notice,
.assignment-inbox {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 12px 0;
  padding: 14px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(53, 37, 10, 0.08);
}

.assignment-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(var(--support-rgb), 0.18);
}

.assignment-notice.hidden,
.assignment-inbox.hidden {
  display: none;
}

.assignment-notice h3,
.assignment-inbox h4 {
  margin: 2px 0 4px;
}

.assignment-notice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.assignment-inbox-list {
  display: grid;
  gap: 8px;
}

.assignment-inbox-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg);
}

.assignment-inbox-card.done {
  opacity: 0.7;
}

.gamification-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(53, 37, 10, 0.08);
}

.gamification-panel.hidden {
  display: none;
}

.gamification-head,
.gamification-level-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gamification-head h3 {
  margin-bottom: 0;
}

.gamification-score {
  min-width: 74px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--accent);
  color: var(--accent-text);
  text-align: center;
}

.gamification-progress {
  height: 9px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
  overflow: hidden;
}

.gamification-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

.overview-section {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}

.overview-section:first-child {
  border-top: 0;
}

.overview-section h3 {
  margin-bottom: 8px;
}

.overview-list {
  margin: 0;
  padding-left: 20px;
}

.dashboard-card {
  display: grid;
  gap: 12px;
}

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

.dashboard-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.dashboard-score {
  min-width: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg);
  text-align: center;
  font-size: 1.1rem;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.dashboard-class-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.dashboard-stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 246, 228, 0.58);
}

.dashboard-stat strong {
  display: block;
  margin-bottom: 2px;
  font-size: 1.1rem;
}

.dashboard-stat span {
  color: var(--muted);
  font-weight: 800;
}

.dashboard-article {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
  background: var(--bg);
  overflow: hidden;
}

.dashboard-article summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 11px 12px;
  cursor: pointer;
}

.dashboard-article summary > span:first-child {
  min-width: 0;
}

.dashboard-pill {
  display: inline-block;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #f4dfad;
  color: #5d4105;
  font-size: 0.76rem;
  font-weight: 900;
  vertical-align: middle;
}

.dashboard-pill.status-not-assigned,
.dashboard-pill.status-missing {
  background: rgba(127, 127, 127, 0.13);
  color: var(--muted);
}

.dashboard-pill.status-new {
  background: #ffe4a8;
  color: #5d4105;
}

.dashboard-pill.status-opened {
  background: #dcecff;
  color: #21466f;
}

.dashboard-pill.status-in-progress {
  background: #efe1ff;
  color: #50306f;
}

.dashboard-pill.status-completed {
  background: #dff3df;
  color: #285d34;
}

.dashboard-pill.status-inactive {
  background: #ffe0dc;
  color: #7b271f;
}

.dashboard-pill.status-active {
  background: #e3f4ee;
  color: #245d43;
}

.dashboard-student-list {
  display: grid;
  gap: 8px;
}

.dashboard-student {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}

.dashboard-student.has-open {
  border-color: rgba(180, 122, 24, 0.42);
}

.dashboard-student.is-inactive {
  border-color: rgba(158, 66, 48, 0.42);
  background: rgba(255, 224, 220, 0.16);
}

.dashboard-student-summary {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(170px, 0.9fr) minmax(180px, 1.2fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  cursor: pointer;
}

.dashboard-student-summary::marker {
  color: var(--muted);
}

.dashboard-student-main,
.dashboard-student-open,
.dashboard-student-status {
  min-width: 0;
}

.dashboard-student-main,
.dashboard-student-open {
  display: grid;
  gap: 2px;
}

.dashboard-student-main small,
.dashboard-student-open small,
.dashboard-assignment-item small {
  color: var(--muted);
  font-weight: 800;
}

.dashboard-student-open span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-student-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.dashboard-detail-link {
  color: var(--accent-dark);
  font-weight: 900;
}

.dashboard-student-detail {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--card);
}

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

.dashboard-student-detail h4 {
  margin: 0 0 8px;
}

.dashboard-assignment-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dashboard-assignment-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--bg);
}

.dashboard-assignment-item > span {
  min-width: 0;
}

.dashboard-article-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.dashboard-list {
  margin: 0;
  padding-left: 18px;
}

.dashboard-answer {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.dashboard-answer p {
  margin-bottom: 4px;
}

.assignment-panel {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 16px;
}

.assignment-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.assignment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg);
}

.assignment-row-completed {
  border-color: rgba(62, 139, 91, 0.35);
  background: rgba(62, 139, 91, 0.08);
}

.assignment-row-in-progress {
  border-color: rgba(116, 85, 156, 0.28);
  background: rgba(116, 85, 156, 0.08);
}

.assignment-row input {
  width: 18px;
  height: 18px;
}

.assignment-row span {
  display: grid;
  gap: 2px;
}

.assignment-row small {
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 560px) {
  .assignment-notice,
  .assignment-inbox-card {
    grid-template-columns: 1fr;
  }

  .assignment-notice {
    display: grid;
  }

  .assignment-notice-actions {
    justify-content: flex-start;
  }

  .dashboard-header,
  .dashboard-article summary,
  .dashboard-student-summary,
  .dashboard-detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    display: grid;
  }

  .dashboard-score {
    width: max-content;
  }

  .dashboard-student-open span {
    white-space: normal;
  }
}

.answer-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin-top: 10px;
}

.answer-card p {
  margin-bottom: 8px;
}

.teacher-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.teacher-tabs .secondary-btn {
  width: auto;
  margin-top: 0;
}

.teacher-tabs .secondary-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.primary-btn {
  width: 100%;
  margin-top: 20px;
  padding: 15px 18px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
}

.primary-btn.compact {
  width: auto;
  margin-top: 0;
  padding: 11px 16px;
}

.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 16, 12, 0.42);
}

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

.quiz-card {
  width: min(100%, 430px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.install-card {
  display: grid;
  gap: 10px;
}

.quiz-prompt {
  margin: 14px 0;
  font-size: 1.55rem;
  font-weight: 900;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 13px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  text-align: left;
}

.quiz-option.correct {
  border-color: rgba(62, 139, 91, 0.75);
  background: rgba(62, 139, 91, 0.18);
}

.quiz-option.wrong {
  border-color: rgba(180, 35, 24, 0.65);
  background: rgba(180, 35, 24, 0.12);
}

.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.setting-row.stacked {
  align-items: stretch;
  flex-direction: column;
}

.setting-note {
  margin: 6px 0 0;
}

select {
  font: inherit;
  padding: 8px 10px;
  border-radius: 12px;
}

@media (max-width: 460px) {
  #app { padding: 14px; }
  h1 { font-size: 1.72rem; }
  .topbar {
    gap: 10px;
    align-items: flex-start;
  }
  .topbar.long-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }
  .topbar.long-title > div:first-child {
    display: contents;
  }
  .topbar.long-title .eyebrow {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
  }
  .topbar.long-title h1 {
    grid-column: 1 / -1;
    grid-row: 2;
    white-space: normal;
  }
  .topbar.long-title .top-actions {
    grid-column: 2;
    grid-row: 1;
  }
  .top-actions {
    gap: 6px;
  }
  .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 16px;
  }
  .reader-card { border-radius: 24px; padding: 20px; }
  .article-card {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  .article-card-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
  }
  .article-card h4 {
    font-size: 1.03rem;
  }
  .word-search-grid { gap: 3px; }
  .letter-cell { border-radius: 6px; font-size: 0.72rem; }
}

@media (max-width: 380px) {
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .top-actions {
    gap: 5px;
  }
}

@media (max-width: 700px) {
  .practice-tabs {
    position: sticky;
    top: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 14px -4px 12px;
    padding: 7px 4px;
    background: color-mix(in srgb, var(--card) 88%, transparent);
    backdrop-filter: blur(10px);
  }

  .practice-tab {
    min-width: 0;
    min-height: 42px;
    padding: 8px 6px;
    border-radius: 14px;
    background: rgba(127, 127, 127, 0.09);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    line-height: 1.12;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .practice-tab.active {
    background: var(--accent);
    color: var(--accent-text);
  }

  .mobile-bottom-nav:not(.hidden) {
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    max-width: 520px;
  }
}
