@font-face {
  font-family: "Funnel Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/funnel-sans/funnel-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Funnel Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/funnel-sans/funnel-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-serif/ibm-plex-serif-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-serif/ibm-plex-serif-500-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-serif/ibm-plex-serif-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-serif/ibm-plex-serif-600-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/vazirmatn/vazirmatn-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891,
    U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
    U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/vazirmatn/vazirmatn-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/vazirmatn/vazirmatn-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f5f2ec;
  --text: #24211d;
  --text-muted: #756f66;
  --text-faint: #9a9389;
  --border: #e4ded4;
  --border-strong: #d2cabd;
  --accent: #2f6f73;
  --accent-soft: #e3f2f3;
  --word-unseen-bg: #dff3ff;
  --word-unseen-border: #a8d8ef;
  --word-learning-bg: #fff3bd;
  --word-learning-border: #ecd77e;
  --danger: #a6423a;
  --danger-soft: #f8e7e5;
  --shadow: 0 18px 50px rgba(52, 44, 34, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Funnel Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  scrollbar-gutter: stable;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.top-nav,
.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}

.landing-shell {
  min-height: 100vh;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.landing-nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1fr);
  gap: 46px;
  align-items: center;
  min-height: calc(100vh - 132px);
  padding: 48px 0 32px;
}

.landing-copy {
  max-width: 520px;
}

.landing-brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}

.landing-mark {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.landing-brand-lockup h1 {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 68px;
  line-height: 0.98;
  letter-spacing: 0;
}

.landing-copy p {
  max-width: 470px;
  margin: 22px 0 0;
  color: var(--text-muted);
  font-size: 19px;
  line-height: 1.65;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.not-found-page {
  min-height: calc(100vh - 132px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 0;
}

.not-found-page p {
  max-width: 440px;
  margin: 22px 0 0;
  color: var(--text-muted);
  font-size: 19px;
  line-height: 1.65;
}

.landing-preview {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: visible;
  padding: 46px 34px;
}

.landing-demo-topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.landing-demo-text {
  display: block;
  direction: rtl;
  font-family: "Vazirmatn", "Noto Sans Arabic", sans-serif;
  font-size: 30px;
  line-height: 2;
}

.landing-preview .reader-legend {
  margin-top: 28px;
}

.landing-demo-card {
  position: absolute;
  z-index: 20;
  width: min(100%, 300px);
  max-width: calc(100% - 24px);
}

.waitlist-shell {
  min-height: 100vh;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.waitlist-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.78fr);
  gap: 42px;
  align-items: center;
  min-height: calc(100vh - 132px);
  padding: 48px 0 32px;
}

.waitlist-copy {
  max-width: 590px;
}

.waitlist-copy .landing-brand-lockup {
  align-items: flex-start;
}

.waitlist-copy .landing-brand-lockup h1 {
  max-width: 480px;
  font-size: 54px;
  line-height: 1.02;
}

.waitlist-copy p {
  max-width: 540px;
  margin: 22px 0 0;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.65;
}

.waitlist-form {
  display: grid;
  gap: 17px;
  max-width: 520px;
  margin-top: 30px;
}

.waitlist-email-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.waitlist-copy .waitlist-note {
  margin: -2px 0 0;
  color: var(--text-faint);
  font-size: 14px;
}

.waitlist-copy .waitlist-success {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  padding: 11px 13px;
  font-size: 15px;
  font-weight: 700;
}

.reader-legend {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.reader-legend-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--text-muted);
  font-size: 15px;
}

.reader-legend-swatch {
  width: 28px;
  height: 18px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.reader-legend-unseen {
  background: var(--word-unseen-bg);
  border-color: var(--word-unseen-border);
}

.reader-legend-learning {
  background: var(--word-learning-bg);
  border-color: var(--word-learning-border);
}

.reader-legend-known {
  background: var(--surface);
  border-color: var(--border-strong);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.login-brand {
  width: max-content;
}

.login-nav {
  min-height: 42px;
}

.login-card {
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 24px;
  width: min(100%, 480px);
  margin: 32px 0;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.login-kicker {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-title {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.login-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 7px;
}

.login-label-row label {
  margin-bottom: 0;
}

.login-link {
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.login-link:hover {
  text-decoration: underline;
}

.login-submit {
  width: 100%;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.4;
}

.login-note {
  margin: -6px 0 0;
  color: var(--text-muted);
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--text-muted);
}

.topbar-streak,
.topbar-pill,
.topbar-user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.topbar-streak {
  gap: 5px;
  padding: 0 8px;
  font-size: 18px;
}

.streak-inactive {
  color: var(--text-faint);
  filter: grayscale(1);
}

.topbar-pill,
.topbar-user {
  gap: 5px;
  padding: 0 10px;
}

.topbar-user {
  min-width: 48px;
}

.language-menu,
.user-menu {
  position: relative;
}

.language-dropdown,
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: none;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.language-menu.open .language-dropdown,
.user-menu.open .user-dropdown {
  display: grid;
  gap: 2px;
}

.language-option,
.language-add,
.language-add-option,
.user-option {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 9px 10px;
  text-align: left;
  text-decoration: none;
}

.user-dropdown {
  min-width: 150px;
}

.user-option {
  grid-template-columns: minmax(0, 1fr);
}

.language-option:hover,
.language-option.active,
.language-add:hover,
.language-add-option:hover,
.user-option:hover {
  background: var(--surface-soft);
}

.language-add {
  grid-template-columns: 26px minmax(0, 1fr) auto;
  margin: 6px -6px -6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  border-radius: 0;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.language-add-panel {
  display: none;
  gap: 2px;
  max-height: min(360px, 58vh);
  margin: 0 -6px -6px;
  padding: 6px;
  border-top: 1px solid var(--border);
  overflow-y: auto;
}

.language-menu.adding-language .language-add-panel {
  display: grid;
}

.language-add-option {
  grid-template-columns: 26px minmax(0, 1fr);
}

.language-menu:not(.adding-language) .language-add {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.danger-option {
  color: var(--danger);
}

.known-count {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.flag-catalonia {
  display: inline-block;
  width: 22px;
  height: 15px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(36, 33, 29, 0.18);
  background: repeating-linear-gradient(
    to bottom,
    #f6d54a 0,
    #f6d54a 3px,
    #c83a32 3px,
    #c83a32 5px
  );
}

.chevron {
  color: var(--text-muted);
  font-size: 13px;
  transform: translateY(-1px);
}

.topbar-streak:hover,
.topbar-pill:hover,
.topbar-user:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-header > div {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

.page-kicker {
  margin: 10px 0 0;
  color: var(--text-muted);
}

.processing-kicker {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin: 26px 0 28px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  color: var(--text);
}

.textarea {
  min-height: 360px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  white-space: nowrap;
}

.button-primary {
  background: var(--text);
  color: #fff;
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.button-ghost {
  background: transparent;
  color: var(--text-muted);
}

.button-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #e5bbb7;
}

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

.section-title {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.card,
.lesson-card,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.lesson-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.lesson-card > div {
  min-width: 0;
}

.lesson-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.lesson-title {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 700;
}

.lesson-card .lesson-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-thread {
  position: relative;
  width: min(260px, 100%);
  height: 3px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  overflow: hidden;
}

.lesson-thread span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.meta {
  color: var(--text-muted);
  font-size: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.status-ready {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-processing {
  background: var(--word-learning-bg);
  color: #776120;
}

.status-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
}

.helper-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.import-textarea {
  font-family: var(--reader-font-family, "IBM Plex Serif", Georgia, serif);
  font-size: 20px;
  line-height: 1.9;
}

.error-message {
  display: none;
  border: 1px solid #e5bbb7;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 12px 14px;
}

.error-message.visible {
  display: block;
}

.processing-card {
  display: grid;
  gap: 22px;
}

.processing-title {
  margin: 0;
  font-size: 22px;
}

.steps {
  display: grid;
  gap: 11px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  color: var(--text-muted);
}

.step.complete {
  color: var(--accent);
}

.step.active {
  color: var(--text);
  font-weight: 700;
}

.step-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .step-spinner {
    animation: none;
  }
}

.reader-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.reader-topbar {
  margin-bottom: 28px;
}

.reader-nav-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.reader-nav-left {
  min-width: 0;
}

.reader-heading {
  text-align: center;
  min-width: 0;
}

.reader-heading h1 {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 28px;
  line-height: 1.2;
}

.reader-thread-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.reader-thread-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.reader-layout {
  max-width: 1040px;
  margin: 0 auto;
  padding-bottom: 56px;
}

.reader-paper {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  padding: 40px;
}

.reader-text {
  font-family: var(--reader-font-family, "Vazirmatn", "Noto Sans Arabic", sans-serif);
  font-size: var(--reader-font-size, 28px);
  line-height: 2.25;
}

.reader-text p {
  margin: 0 0 1.4em;
}

.reader-audio-player {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  width: min(720px, calc(100vw - 32px));
  transform: translateX(-50%);
}

.audio-play {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0 !important;
  border-radius: 999px;
  padding: 0;
  background: transparent !important;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.audio-play:hover {
  background: transparent !important;
}

.audio-play-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #000;
  color: var(--surface);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  transition: background-color 120ms ease;
  padding-bottom: 1px;
}

.audio-play.is-paused .audio-play-icon {
  font-size: 0;
  padding-bottom: 0;
}

.audio-play.is-paused .audio-play-icon::before,
.audio-play.is-paused .audio-play-icon::after,
.audio-expanded-play.is-paused::before,
.audio-expanded-play.is-paused::after {
  content: "";
  width: 4px;
  height: 17px;
  border-radius: 999px;
  background: currentColor;
}

.audio-play.is-paused .audio-play-icon,
.audio-expanded-play.is-paused {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.audio-play:hover .audio-play-icon {
  background: #3a332c;
}

.audio-play:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.audio-expanded-panel {
  width: 100%;
  padding: 12px 14px;
  background: rgba(251, 250, 247, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 46px rgba(52, 44, 34, 0.13);
  backdrop-filter: blur(10px);
}

.audio-expanded-panel[hidden] {
  display: none;
}

.audio-progress-row {
  margin: 0 8px 8px;
}

.audio-progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  cursor: pointer;
  --audio-progress-color: var(--word-learning-border);
  --audio-track-color: rgba(80, 70, 55, 0.24);
  --audio-thumb-color: var(--word-learning-border);
}

.audio-progress::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--audio-progress-color) 0%,
    var(--audio-progress-color) var(--progress-percent),
    var(--audio-track-color) var(--progress-percent),
    var(--audio-track-color) 100%
  );
}

.audio-progress::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: var(--audio-track-color);
}

.audio-progress::-moz-range-progress {
  height: 3px;
  border-radius: 999px;
  background: var(--audio-progress-color);
}

.audio-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: none;
  background: var(--audio-thumb-color);
  margin-top: -4.5px;
}

.audio-progress::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: none;
  background: var(--audio-thumb-color);
}

.audio-expanded-main {
  position: relative;
  display: grid;
  grid-template-columns: auto auto auto auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.audio-expanded-main button {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.audio-close {
  grid-column: 8;
  position: relative;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border) !important;
  border-radius: 999px;
  background: var(--surface) !important;
  color: var(--text-muted) !important;
  font-size: 0 !important;
  line-height: 1;
  padding: 0;
}

.audio-close::before {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: currentColor;
  font-size: 24px;
  line-height: 1;
  transform: translateY(-1px);
}

.audio-expanded-play:hover {
  background: color-mix(in srgb, var(--text) 88%, white) !important;
}

.audio-close:hover {
  color: var(--danger) !important;
  border-color: #e5bbb7 !important;
  background: var(--danger-soft) !important;
}

.audio-current-time,
.audio-duration {
  color: #1b1814;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.audio-thread {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: #efebe4;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  margin-top: 0;
  align-self: center;
  width: 100%;
}

.audio-scroll-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  margin-left: 8px;
  margin-right: 4px;
}

.audio-thread-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.audio-sentence {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.audio-skip,
.audio-speed {
  min-height: 32px;
  border: 1px solid var(--border) !important;
  border-radius: 999px;
  padding: 6px 11px;
  background: var(--surface) !important;
  color: #1b1814 !important;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.audio-speed-wrap {
  position: relative;
  display: inline-flex;
}

.audio-speed-menu {
  position: absolute;
  left: 50%;
  bottom: 42px;
  z-index: 45;
  display: grid;
  gap: 4px;
  min-width: 86px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.audio-speed-menu[hidden] {
  display: none;
}

.audio-speed-option {
  min-height: 30px;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  text-align: left;
}

.audio-speed-option:hover {
  background: var(--surface-soft);
}

.audio-skip:hover,
.audio-speed:hover {
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
  background: var(--surface-soft) !important;
}

.word {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.03em 0.13em;
  margin-inline: 0.01em;
  border-radius: 0.28em;
  cursor: pointer;
}

.word-unseen {
  background: var(--word-unseen-bg);
  box-shadow: inset 0 -1px 0 var(--word-unseen-border);
}

.word-learning {
  background: var(--word-learning-bg);
  box-shadow: inset 0 -1px 0 var(--word-learning-border);
}

.word-known,
.word-ignored {
  background: transparent;
}

.word:hover {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.word-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.word-popover {
  position: fixed;
  z-index: 50;
}

.word-popover[hidden] {
  display: none;
}

.word-popover-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 70px rgba(52, 44, 34, 0.18);
  overflow: hidden;
}

.word-popover-card::before {
  content: "";
  position: absolute;
  top: -7px;
  left: calc(50% - 7px);
  width: 14px;
  height: 14px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

.word-popover-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 8px;
}

.word-popover-title {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
}

.word-audio-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(36, 33, 29, 0.06);
}

.word-audio-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.word-popover-surface {
  font-family: "Vazirmatn", "Noto Sans Arabic", sans-serif;
  font-size: 24px;
  line-height: 1.35;
}

.word-popover-normalized {
  color: var(--text-muted);
  font-family: "Vazirmatn", "Noto Sans Arabic", sans-serif;
  font-size: 16px;
}

.word-popover-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.word-popover-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.word-header-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.word-header-status:hover {
  opacity: 0.72;
}

.word-header-status-ignored {
  color: var(--danger);
}

.word-header-status-known {
  color: var(--accent);
  font-size: 13px;
}

.word-header-status-learning {
  border: 1px solid var(--word-learning-border);
  border-radius: 999px;
  background: var(--word-learning-bg);
  color: #776120;
  font-size: 13px;
  padding: 0 8px;
}

.header-status-menu {
  position: absolute;
  z-index: 2;
  min-width: 164px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(52, 44, 34, 0.16);
}

.header-status-menu[hidden] {
  display: none;
}

.word-popover-close:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.word-popover-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 14px 10px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-faint);
}

.status-unseen {
  background: var(--word-unseen-border);
}

.status-learning {
  background: var(--word-learning-border);
}

.status-known,
.status-ignored {
  background: var(--accent);
}

.word-popover-section {
  border-top: 1px solid var(--border);
  padding: 11px 14px;
}

.word-popover-section h2 {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.word-popover-section p {
  margin: 0;
  color: var(--text);
}

.meaning-chip {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: default;
  padding: 9px 10px;
  text-align: left;
}

.word-popover-expanded[hidden] {
  display: none;
}

.word-popover-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 34px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.word-popover-toggle:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.status-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.popover-actions {
  border-top: 1px solid var(--border);
  margin: 0;
  padding: 14px;
}

.header-status-actions {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: stretch;
  gap: 6px;
}

.status-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}

.status-action:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-soft);
}

.status-action.selected {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text-faint);
  cursor: default;
  box-shadow: inset 0 1px 2px rgba(36, 33, 29, 0.08);
  opacity: 0.78;
}

.status-action.selected:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text-faint);
}

.status-action-ignored.selected,
.status-action-ignored.selected:hover {
  border-color: #e5bbb7;
  background: var(--danger-soft);
  color: var(--danger);
}

.status-action-learning.selected,
.status-action-learning.selected:hover {
  border-color: var(--word-learning-border);
  background: var(--word-learning-bg);
  color: #776120;
}

.status-action-known.selected,
.status-action-known.selected:hover {
  border-color: rgba(47, 111, 115, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.status-action-icon {
  font-size: 17px;
}

.status-action-text {
  width: auto;
  min-width: 72px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
}

.status-action-labelled {
  justify-content: flex-start;
  width: 100%;
  gap: 10px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 0 8px;
  box-shadow: none;
}

.status-action-labelled .status-action-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.status-action-label {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status-action-labelled:hover {
  background: var(--surface-soft);
  border-color: transparent;
}

.status-action-labelled.selected {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  opacity: 1;
}

.status-action-labelled.selected:hover {
  background: var(--surface-soft);
}

.status-action-labelled.selected .status-action-mark {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text-faint);
  box-shadow: inset 0 1px 2px rgba(36, 33, 29, 0.08);
}

.status-action-labelled.status-action-ignored.selected .status-action-mark {
  border-color: #e5bbb7;
  background: var(--danger-soft);
  color: var(--danger);
}

.status-action-labelled.status-action-learning.selected .status-action-mark {
  border-color: var(--word-learning-border);
  background: var(--word-learning-bg);
  color: #776120;
}

.status-action-labelled.status-action-known.selected .status-action-mark {
  border-color: rgba(47, 111, 115, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-grid {
  display: grid;
  gap: 18px;
}

.settings-section {
  display: grid;
  gap: 14px;
}

.settings-note {
  color: var(--text-muted);
  font-size: 14px;
}

.profile-card {
  margin-bottom: 14px;
}

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

.profile-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface-soft);
}

.profile-stat-value,
.profile-stat-label {
  display: block;
}

.profile-stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.profile-stat-label {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.profile-chart {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.profile-line-chart {
  position: relative;
  display: grid;
  gap: 8px;
}

.profile-chart-empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  min-height: 190px;
  align-content: center;
  padding: 28px 0;
  color: var(--text-muted);
}

.profile-chart-empty p {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.profile-chart-empty span {
  max-width: 360px;
  font-size: 14px;
}

.profile-chart-empty .button {
  margin-top: 6px;
}

.profile-line-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.profile-line-grid {
  stroke: var(--border);
  stroke-opacity: 0.62;
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
}

.profile-line-tick {
  stroke: var(--border);
  stroke-opacity: 0.58;
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
}

.profile-line-path {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.profile-line-point {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.profile-line-hover-zone {
  fill: transparent;
  outline: none;
}

.profile-line-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 180px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(52, 44, 34, 0.12);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
}

.profile-line-tooltip[hidden] {
  display: none;
}

.profile-line-labels {
  display: grid;
  grid-template-columns: repeat(var(--chart-points, 7), minmax(0, 1fr));
  gap: 3px;
  margin-top: 6px;
  padding: 0 calc(32 / 700 * 100%);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.profile-line-labels strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.profile-line-label-empty {
  visibility: hidden;
}

.profile-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-section-header .section-title {
  margin-bottom: 0;
}

.profile-chart-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-sort-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  white-space: nowrap;
}

.profile-sort-option {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 5px 11px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.profile-sort-option:hover {
  color: var(--text);
}

.profile-sort-option.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(47, 111, 115, 0.18);
}

.profile-range-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.profile-range-select {
  width: auto;
  min-height: 34px;
  padding: 6px 28px 6px 10px;
  border-radius: 999px;
  font-size: 14px;
}

.profile-language-list {
  display: grid;
  gap: 6px;
}

.profile-language-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  padding: 7px 8px;
}

.profile-language-row:hover {
  background: var(--surface-soft);
}

.profile-language-name {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-weight: 700;
}

@media (max-width: 820px) {
  .app-shell,
  .reader-shell {
    padding: 22px 16px 96px;
  }

  .landing-shell {
    padding: 22px 16px 42px;
  }

  .waitlist-shell {
    padding: 22px 16px 42px;
  }

  .login-shell {
    padding: 22px 16px 42px;
  }

  .login-card {
    padding: 22px 18px;
  }

  .login-title {
    font-size: 30px;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    gap: 30px;
    min-height: auto;
    padding: 42px 0 24px;
  }

  .landing-mark {
    width: 54px;
    height: 54px;
  }

  .landing-brand-lockup h1 {
    font-size: 48px;
  }

  .landing-brand-lockup {
    display: none;
  }

  .waitlist-page {
    grid-template-columns: 1fr;
    gap: 30px;
    min-height: auto;
    padding: 42px 0 24px;
  }

  .waitlist-copy .landing-brand-lockup {
    display: inline-flex;
  }

  .waitlist-copy .landing-brand-lockup h1 {
    font-size: 40px;
  }

  .waitlist-email-row {
    grid-template-columns: 1fr;
  }

  .waitlist-email-row .button {
    width: 100%;
  }

  .landing-copy p {
    font-size: 17px;
  }

  .landing-preview {
    min-height: 280px;
    padding: 28px 18px;
  }

  .landing-demo-text {
    font-size: 24px;
  }

  .page-header,
  .toolbar,
  .lesson-card,
  .reader-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .page-header,
  .reader-topbar {
    display: grid;
  }

  .page-title {
    font-size: 34px;
  }

  .reader-paper {
    padding: 24px 18px;
  }

  .reader-text {
    font-size: clamp(21px, var(--reader-font-size, 23px), 30px);
    line-height: 2.15;
  }

  .reader-audio-player {
    bottom: 18px;
    left: 50%;
    width: calc(100vw - 24px);
  }

  .audio-expanded-panel {
    width: 100%;
    border-radius: var(--radius-lg);
    padding: 12px;
  }

  .audio-expanded-main {
    grid-template-columns: auto auto auto auto auto minmax(36px, 1fr);
    gap: 8px;
  }

  .audio-progress-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .audio-duration {
    display: none;
  }

  .audio-sentence {
    display: none;
  }

  .profile-stats {
    grid-template-columns: 1fr;
  }

  .profile-line-labels {
    gap: 7px;
  }

  .profile-section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-chart-controls {
    justify-content: flex-start;
  }
}
