/* Final UI layer: preserve content, reading size and the existing brand assets. */
:root {
  --ui-blue: #1279c5;
  --ui-blue-dark: #155b91;
  --ui-blue-soft: #edf6ff;
  --ui-orange: #d77516;
  --ui-orange-soft: #fff3e2;
  --ui-focus: #e68424;
  --ui-muted: #58728f;
}

/* One optical weight for the navigation, reading tools and practice controls. */
.icon,
.practice-panel .practice-icon {
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
}

button,
a,
summary,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

:is(button, a, summary, input, select, textarea):focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 3px;
}

.word:focus-visible {
  outline-offset: 1px;
  border-radius: 3px;
  background: #e5f1ff;
}

:where(.btn, .practice-action, .font-controls button, .sheet-close,
  .sentence-toggle, .mobile-nav a, .reader-mode a, .home-collection-switch button) {
  touch-action: manipulation;
}

:where(.btn, .practice-action, .font-controls button, .sheet-close,
  .sentence-toggle, .mobile-nav a, .reader-mode a, .practice-option) {
  transition: background-color .15s ease, border-color .15s ease,
    color .15s ease, box-shadow .15s ease, transform .15s ease;
}

/* Progress is the focal point; supporting counts retain a quiet card treatment. */
.learning-dashboard {
  border-color: #c6def4;
  box-shadow: 0 4px 0 #e2edf9;
}

.learning-dashboard-head {
  align-items: flex-start;
}

.learning-dashboard-head > div {
  min-width: 0;
}

.learning-kicker {
  color: #4476a1;
}

.learning-sticker {
  flex: none;
  color: #9a4c0b;
  background: var(--ui-orange-soft);
}

.learning-progress-label {
  color: #355b80;
}

.learning-progress-label strong,
.learning-counts strong,
.completion-stats strong,
.profile-stat-grid strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}

.learning-progress-track {
  height: 12px;
  background: #eaf2fc;
}

.learning-progress-track > span {
  background: linear-gradient(90deg, #1684d4, #42a5e8);
}

.learning-counts > div,
.learning-counts > a {
  border: 1px solid #e0edfa;
}

.learning-counts > a {
  border-color: #f3ddbb;
}

.learning-counts > div > .icon,
.learning-counts > a > .icon:first-child {
  width: 22px;
  height: 22px;
}

.learning-counts small,
.learning-footnote,
.completion-note {
  color: var(--ui-muted);
}

.learning-counts > a:active {
  background: #ffecd1;
  border-color: #e9bd7f;
}

/* A clear achievement and one primary next step, without extra decoration. */
.completion-card {
  background: linear-gradient(180deg, #f4faff, #fff 160px);
  border-color: #bfddf6;
  scroll-margin-block: 24px;
}

.completion-card:focus {
  outline: 3px solid #f0ba75;
  outline-offset: 4px;
}

.completion-badge {
  transform: none;
  border-color: #f0be7d;
  color: #b76210;
  background: #fff1d9;
  box-shadow: 0 3px 0 #f4dec0;
}

.completion-badge .icon {
  stroke-width: 2.2;
}

.completion-card h2 {
  letter-spacing: -.3px;
}

.completion-stats > div {
  justify-content: flex-start;
}

.completion-stats span {
  color: #4d6989;
  white-space: normal;
  overflow-wrap: anywhere;
}

.completion-actions .btn.outline {
  box-shadow: none;
  background: #fff;
}

.completion-wordbook {
  color: var(--ui-blue-dark);
  border-radius: 10px;
}

/* Reading controls stay distinct from the English reading area. */
.mobile-reading-tools > .text-link,
.font-controls button {
  min-height: 44px;
  color: var(--ui-blue-dark);
  background: #f1f7ff;
  border: 1px solid #cfe1f4;
  border-radius: 10px;
}

.mobile-reading-tools > .text-link {
  justify-content: center;
  padding: 9px 12px;
}

.reading-tool {
  color: var(--ui-muted);
}

.font-controls button {
  flex: none;
  font-weight: 700;
  font-family: var(--sans, sans-serif);
}

.sentence-toggle {
  border: 1px solid transparent;
  color: #326f9f;
  background: #f0f7ff;
  font-weight: 700;
}

.sentence-toggle[aria-expanded="true"] {
  background: #deedff;
  border-color: #bdd8f2;
  color: #175b94;
}

.sentence-en .word:active {
  color: #125a94;
  background: #dceeff;
  border-radius: 3px;
}

:is(.font-controls button, .sheet-close, .mobile-reading-tools > .text-link,
  .sentence-toggle, .reader-mode a):active {
  color: #155c94;
  background: #dcecff;
}

.reader-mode a {
  color: #587899;
}

.reader-mode a.active {
  color: #165f99;
}

.sheet-close {
  color: #326e9c;
}

.sheet-close .icon {
  width: 19px;
  height: 19px;
}

.sheet-actions .btn[aria-pressed="true"] {
  border: 1px solid #b5d7f2;
  background: #e7f3ff;
  color: #185e96;
}

/* Submitted answers remain readable, while disabled actions look inactive. */
button:disabled,
button[aria-disabled="true"] {
  cursor: default;
}

.btn:disabled,
.btn[aria-disabled="true"],
.practice-action:disabled,
.font-controls button:disabled {
  opacity: 1;
  color: #738296;
  background: #e8edf3;
  border-color: #d5dee8;
  box-shadow: none;
  transform: none;
}

.practice-panel .practice-option:disabled {
  opacity: 1;
  transform: none;
}

.practice-panel .practice-option:disabled:not(.is-answer):not(.is-wrong) {
  color: #566e8b;
  background: #f5f8fc;
}

.practice-panel .practice-option.is-selected {
  border-color: #4b99d4;
}

.practice-panel .authored-options .practice-choice-text {
  color: inherit;
}

.practice-panel .practice-authored-analysis,
.practice-panel .practice-question-feedback p {
  color: #3c5d7c;
}

@media (hover: hover) and (pointer: fine) {
  .learning-counts > a:hover {
    border-color: #e9bd7f;
    background: #fff0db;
  }

  :where(.font-controls button, .sheet-close, .mobile-reading-tools > .text-link):hover {
    color: #165f99;
    background: #e2efff;
    border-color: #b9d5ee;
  }

  .completion-wordbook:hover {
    background: #edf6ff;
  }
}

@media (max-width: 760px) {
  .mobile-nav {
    gap: 2px;
    padding: 6px 8px calc(7px + env(safe-area-inset-bottom));
    border-top-color: #d5e4f5;
    box-shadow: 0 -4px 18px #3b66970c;
  }

  .mobile-nav a {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    color: #607a98;
    font-size: 11px;
    line-height: 1.3;
    gap: 4px;
    border-radius: 12px;
  }

  .mobile-nav a .icon {
    width: 22px;
    height: 22px;
    stroke-width: 1.85;
  }

  .mobile-nav a.active {
    color: #126bb0;
    background: #eaf4ff;
    font-weight: 750;
  }

  .mobile-nav a.active .icon {
    filter: none;
  }

  .mobile-nav a.active::before {
    content: "";
    position: absolute;
    top: 5px;
    right: calc(50% - 16px);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #ef8a2c;
    box-shadow: 0 0 0 2px #eaf4ff;
  }

  .mobile-nav a:active {
    background: #deedff;
  }

  .learning-dashboard {
    padding: 18px 16px;
  }

  .learning-dashboard h2 {
    font-size: 18px;
    line-height: 1.5;
  }

  .learning-counts {
    gap: 8px;
  }

  .learning-counts > div,
  .learning-counts > a {
    padding: 12px 10px;
    gap: 8px;
    min-height: 76px;
  }

  .learning-counts small {
    font-size: 11px;
    line-height: 1.5;
  }

  .learning-footnote {
    font-size: 11px;
    line-height: 1.8;
  }

  .completion-card h2 {
    font-size: 20px;
    line-height: 1.5;
  }

  .completion-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .completion-stats > div {
    padding: 13px 3px;
  }

  .completion-stats span {
    font-size: 11px;
    line-height: 1.6;
  }

  .completion-note {
    font-size: 11px;
    line-height: 1.8;
  }

  .completion-actions .btn,
  .reader-finish .btn {
    min-height: 48px;
    font-size: 13px;
  }

  .completion-wordbook {
    min-height: 44px;
    font-size: 12px;
  }

  .mobile-reading-tools {
    flex-wrap: wrap;
    gap: 9px 10px;
    align-items: center;
  }

  .mobile-reading-tools > .text-link {
    flex: 1 1 auto;
    font-size: 12px;
  }

  .mobile-reading-tools .reading-tool {
    gap: 8px;
    flex: none;
    font-size: 11px;
  }

  .mobile-reading-tools .font-controls {
    gap: 5px;
  }

  .reading-help,
  .reader-meta {
    color: #5d7b9b;
  }

  .reading-help {
    font-size: 11px;
    line-height: 1.75;
  }

  .reader-finish p {
    color: #5b7693;
    line-height: 1.8;
  }

  .word-sheet {
    overscroll-behavior: contain;
    scroll-padding-bottom: 24px;
  }

  .word-sheet .sheet-actions {
    flex-wrap: wrap;
  }

  .word-sheet .sheet-actions .btn {
    min-width: min(100%, 170px);
    min-height: 48px;
    font-size: 12px;
  }

  .practice-panel .authored-options .practice-choice-text {
    font-size: 14px;
    line-height: 1.8;
  }

  .practice-panel .practice-question-feedback strong,
  .practice-panel .practice-question-feedback p {
    font-size: 12px;
    line-height: 1.8;
  }

  .toast {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .learning-dashboard {
    padding: 16px 13px;
  }

  .learning-dashboard h2 {
    font-size: 17px;
  }

  .learning-counts > div,
  .learning-counts > a {
    gap: 6px;
    padding: 11px 8px;
  }

  .learning-counts > div > .icon,
  .learning-counts > a > .icon:first-child {
    width: 18px;
    height: 18px;
  }

  .learning-counts strong {
    font-size: 23px;
  }

  .completion-card h2 {
    font-size: 18px;
  }

  .completion-stats strong {
    font-size: 22px;
  }

  .completion-stats span {
    font-size: 11px;
  }

  .mobile-reading-tools > .text-link {
    flex-basis: 100%;
  }

  .mobile-reading-tools .reading-tool {
    margin-left: auto;
  }

  .sentence-toggle {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .learning-progress-track > span,
  :where(.btn, .practice-action, .font-controls button, .sheet-close,
    .sentence-toggle, .mobile-nav a, .reader-mode a, .practice-option) {
    transition: none;
  }
}
