:root {
  --purple: #1b2a4a;
  --purple-dark: #0f172a;
  --purple-light: #e2e8f0;
  --green: #2d5a27;
  --green-dark: #15803d;
  --bg: #fffefa;
  --bg-soft: #f8fafc;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #cbd5e1;
  --danger: #991b1b;
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
  --shadow: 0 16px 42px rgba(15, 23, 42, 0.09);
  --nav-height: 72px;
  --header-height: 76px;
  --coral: #c59b27;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-soft);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  height: calc(var(--header-height) + env(safe-area-inset-top));
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 18px 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--purple);
  letter-spacing: -0.5px;
}
.brand-emoji { font-size: 22px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notification-btn {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: #d85a4f;
  color: white;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.icon-btn {
  background: var(--purple-light);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.icon-btn:active { transform: scale(0.92); }
.install-app-btn { color: #21483d; background: #e8f1ed; }

/* Main view */
.main-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px calc(var(--nav-height) + 24px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: none;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Conversation workspace */
  .wa-list-header { padding: 20px 2px 8px; }
  .wa-list-header h2 { margin: 0; font-size: 13px; color: var(--text-muted); }
  .wa-chat-list { display: flex; flex-direction: column; }
  .wa-list-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 10px; border-bottom: 1px solid #e8eeeb;
    cursor: pointer; transition: background 0.15s ease;
  }
  .wa-list-item:hover, .wa-list-item:focus-visible { background: #f4f8f6; outline: none; }
  .wa-list-item:active { background: #edf4f1; }
  .wa-avatar {
    width: 46px; height: 46px; border-radius: 5px; flex-shrink: 0;
    background: #e8f1ed; color: #245d4d;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; letter-spacing: 0;
  }
  .wa-avatar.small { width: 40px; height: 40px; font-size: 12px; }
  .wa-avatar.partner-avatar { background: #e9edf4; color: #415775; }
  .wa-list-body { flex: 1; min-width: 0; }
  .wa-list-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .wa-list-name { font-weight: 700; font-size: 14px; }
  .wa-list-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
  .wa-list-preview {
    margin-top: 4px; font-size: 12px; color: var(--text-muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .wa-list-email {
    margin-top: 2px; font-size: 11px; color: var(--text-muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }

.wa-chat-screen {
    position: fixed; z-index: 50; inset: 0;
    width: 100%; height: 100dvh;
    display: flex; flex-direction: column;
    overflow: hidden; background: #fff; border: none; border-radius: 0;
    box-shadow: none;
  }
  .wa-header {
    display: flex; align-items: center; gap: 13px; min-height: 64px;
    padding: 12px 20px; background: var(--purple-dark); color: #fff;
    border-bottom: 2px solid var(--coral); flex-shrink: 0;
  }
  .wa-composer {
    flex-shrink: 0;
    position: sticky; bottom: 0; z-index: 20;
    background: #fff; border-top: 1px solid #e7eeeb;
  }
  .composer-attachments {
    display: flex; flex-wrap: wrap; gap: 8px;
    max-height: 132px; overflow-y: auto;
    padding: 10px 12px 0;
  }
  .composer-attachments.hidden { display: none; }
  .composer-attachment {
    position: relative; display: flex; align-items: center; gap: 8px;
    padding: 6px 28px 6px 6px; border: 1px solid #dce5e1; border-radius: 8px;
    background: #f6faf8; max-width: 180px;
  }
  .composer-attachment-thumb {
    width: 40px; height: 40px; border-radius: 5px; object-fit: cover;
    flex-shrink: 0; background: #e8f1ed;
  }
  .composer-attachment-icon {
    width: 40px; height: 40px; display: grid; place-items: center;
    flex-shrink: 0; border-radius: 5px; background: #e8f1ed; font-size: 18px;
  }
  .composer-attachment-name {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-size: 12px; font-weight: 600; color: #35594c;
  }
  .composer-attachment-remove {
    position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
    display: grid; place-items: center; border: 0; border-radius: 50%;
    background: rgba(33, 72, 61, 0.82); color: #fff; font-size: 14px;
    line-height: 1; cursor: pointer;
  }
  .composer-attachment-remove:hover { background: #b52e33; }
  .wa-input-row {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: #fff; flex-shrink: 0;
  }
  .wa-input-row input,
  .wa-input-row textarea {
    flex: 1; min-width: 0; min-height: 44px; max-height: 120px; border: 1px solid #dce5e1;
    border-radius: 6px; padding: 10px 12px; background: #fbfcfc; font-size: 16px !important;
    line-height: 1.4; resize: none;
  }

  .wa-back-btn, .wa-menu-btn {
    width: 36px; height: 36px; border: 1px solid #e0e8e4; border-radius: 4px;
    background: #fff; color: #465b53; cursor: pointer; flex-shrink: 0;
  }
  .wa-back-btn { font-size: 22px; line-height: 1; }
  .wa-back-btn:hover, .wa-menu-btn:hover { background: #f3f7f5; }
  .wa-header-info { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
  .wa-header-name { font-weight: 750; font-size: 15px; }
  .wa-header-status { color: #668076; font-size: 12px; }
  .wa-header-email { color: #668076; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wa-menu-btn { font-size: 13px; letter-spacing: 1px; }

  .wa-chat-bg {
    flex: 1; overflow-y: auto; padding: 28px clamp(18px, 6vw, 64px);
    display: flex; flex-direction: column; gap: 14px; background: #f5f8f7;
    scrollbar-color: #c7d4ce transparent; scrollbar-width: thin;
  }
  .wa-date-sep {
    align-self: center; color: #71837b; font-size: 11px; font-weight: 650;
    padding: 5px 10px; margin: 2px 0 8px; border: 1px solid #e1e9e5;
    border-radius: 4px; background: #fff;
  }
  .msg {
    position: relative; max-width: min(72%, 620px); padding: 12px 14px 28px;
    border: 1px solid #e1e9e5; border-radius: 5px; font-size: 14px;
    line-height: 1.55; animation: msgIn 0.18s ease; overflow-wrap: anywhere;
  }
  @keyframes msgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
  .msg.mine { align-self: flex-end; padding-top: 30px; background: #21483d; color: #fff; border-color: #21483d; }
  .msg.theirs, .msg.ai { align-self: flex-start; background: #fff; color: #24332d; }
  .msg.ai { border-left: 3px solid #58a783; }
  .msg .correction {
    margin-top: 10px; padding-top: 9px; border-top: 1px solid #e7eeeb;
    color: #536960; font-size: 12px; line-height: 1.5;
  }
  .msg .correction strong { color: #277052; }
  .msg-time {
    position: absolute; bottom: 7px; right: 10px;
    font-size: 10px; color: #73857d; white-space: nowrap;
  }
  .msg.mine .msg-time { color: #b8d2c7; }
  .msg-ticks { color: #b7d9ca; }
  .msg-delete-btn {
    position: absolute; top: 3px; right: 5px; display: grid; width: 24px; height: 24px;
    place-items: center; border: 0; border-radius: 4px; background: transparent;
    color: #87958d; font-size: 18px; line-height: 1; cursor: pointer;
  }
  .msg.mine .msg-delete-btn { color: #d2e5da; }
  .msg-delete-btn:hover { background: rgba(120, 140, 128, 0.14); color: #b52e33; }
  .msg-delete-btn:disabled { cursor: wait; opacity: 0.5; }

  .wa-typing-bubble { display: flex; gap: 4px; align-items: center; padding: 14px; }
  .wa-typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #709084; animation: typingBounce 1.1s infinite ease-in-out; }
  .wa-typing-dot:nth-child(2) { animation-delay: 0.15s; }
  .wa-typing-dot:nth-child(3) { animation-delay: 0.3s; }
  @keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

  .wa-input-row {
    display: flex; align-items: center; gap: 10px; padding: 14px 20px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid #e7eeeb; flex-shrink: 0;
  }
  .wa-input-row input,
  .wa-input-row textarea {
    flex: 1; min-width: 0; min-height: 46px; max-height: 136px; border: 1px solid #dce5e1;
    border-radius: 4px; padding: 11px 14px; background: #fbfcfc; font-size: 14px;
  }
  .wa-input-row input:focus,
  .wa-input-row textarea:focus { border-color: #55967a; outline: 2px solid rgba(85, 150, 122, 0.14); }
  .wa-input-row textarea { resize: none; line-height: 1.4; }
  .wa-attach-btn, .wa-send-btn {
    width: 42px; height: 42px; border-radius: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
  }
  .wa-attach-btn { border: 1px solid #dce5e1; background: #fff; color: #49635a; font-size: 22px; }
  .wa-send-btn { border: 1px solid #21483d; background: #21483d; color: #fff; font-size: 22px; }
  .wa-attach-btn:hover { background: #f3f7f5; }
  .wa-send-btn:hover { background: #183a31; }
  .wa-send-btn:active { transform: translateY(1px); }
  .wa-send-btn:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }

  .chat-attachment { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; align-items: center; min-width: min(260px, 60vw); }
  .attachment-preview { grid-column: 1 / -1; width: 100%; max-width: 360px; max-height: 280px; object-fit: contain; background: #edf2ef; }
  .attachment-file-icon { width: 42px; height: 42px; display: grid; place-items: center; background: #e8f1ed; color: #245d4d; font-size: 11px; font-weight: 800; }
  .attachment-details { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
  .attachment-details strong, .attachment-details span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .attachment-details strong { font-size: 12px; }
  .attachment-details span { color: var(--text-muted); font-size: 10px; }
  .attachment-download { grid-column: 2; justify-self: start; border: 0; padding: 0; background: transparent; color: #277052; font-size: 12px; font-weight: 700; cursor: pointer; }
  .msg.mine .attachment-details span { color: #b8d2c7; }
  .msg.mine .attachment-download { color: #d3e9df; }

  .wa-call-btn { width: 40px; height: 40px; flex-shrink: 0; border: 1px solid #dce5e1; border-radius: 4px; background: #fff; color: #245d4d; font-size: 19px; cursor: pointer; }
  .wa-call-btn:hover { background: #f3f7f5; }
  .wa-call-btn:disabled { cursor: wait; opacity: 0.6; }
  .voice-call-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid #dce5e1; background: #edf5f1; color: #21483d; font-size: 13px; }
  .voice-call-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .voice-call-actions button { min-height: 36px; padding: 7px 12px; border: 1px solid #b9cec4; border-radius: 4px; background: #fff; color: #21483d; font-size: 12px; font-weight: 700; cursor: pointer; }
  .voice-call-actions .call-accept-btn { border-color: #21483d; background: #21483d; color: #fff; }
  .voice-call-actions .call-end-btn { border-color: #a84444; background: #a84444; color: #fff; }
  #remoteCallAudio { display: none; }

  @media (max-width: 600px) {
    .wa-chat-screen {
      inset: 0; width: auto; height: auto; max-width: none;
      transform: none; border: 0; border-radius: 0; box-shadow: none;
    }
    .wa-header { min-height: 64px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
    .wa-chat-bg { padding: 18px 14px; gap: 10px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
    .msg { max-width: 88%; }
    .wa-input-row { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
    .wa-input-row input, .wa-input-row textarea { font-size: 16px; }
    .voice-call-panel { align-items: flex-start; flex-direction: column; padding: 10px 14px; }
    .voice-call-actions { width: 100%; }
    .voice-call-actions button { flex: 1 1 auto; }
    .chat-attachment { min-width: min(220px, 58vw); }
  }

textarea { resize: vertical; min-height: 70px; }


/* ДИЗАЙНИ АКАДЕМИКИИ РАВЗАНАИ ЛОГИН (AUTH / ONBOARDING) */
.auth-screen, .onboarding-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - var(--header-height));
}
.auth-screen {
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 24px 0;
}
.auth-logo {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  align-self: center;
  margin-bottom: 16px;
  border: 2px solid var(--coral);
  border-radius: 50%;
  background: var(--purple-dark);
  color: var(--coral);
  font-size: 38px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2);
}
.auth-title { 
  margin: 0; 
  text-align: center; 
  color: var(--purple-dark); 
  font-family: Georgia, serif;
  font-weight: 700; 
  font-size: 28px; 
  line-height: 1.15; 
}
.auth-tagline { 
  max-width: 320px; 
  margin: 8px auto 24px; 
  text-align: center; 
  color: var(--text-muted); 
  font-size: 14px; 
  line-height: 1.5; 
  font-style: italic;
}
.auth-form {
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--purple-dark);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
}
.auth-form-title { 
  margin: 0 0 18px; 
  color: var(--purple-dark); 
  font-family: Georgia, serif; 
  font-size: 19px; 
  text-align: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.auth-form .field label { 
  color: var(--purple-dark); 
  font-size: 11px; 
  font-weight: 800; 
  letter-spacing: 0.8px; 
  text-transform: uppercase; 
  margin-bottom: 6px;
  display: block;
}
.auth-form input { 
  min-height: 46px; 
  border: 1px solid var(--border); 
  border-radius: 4px; 
  background: #f8fafc; 
  color: var(--text);
  font-size: 15px;
  padding: 0 14px;
}
.auth-form input:focus { 
  border-color: var(--purple-dark); 
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.12); 
  outline: none;
}
.auth-method-title { margin: 0 0 8px; font-size: 15px; line-height: 1.3; }
.auth-method-hint { margin: 0 0 14px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.auth-code-sent { margin: 0 0 14px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.auth-method .field { margin-bottom: 14px; }
.auth-code-actions { display: flex; justify-content: space-between; gap: 8px; }
.auth-code-actions .link-btn { width: auto; padding: 10px 4px; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-form .field { margin-bottom: 18px; }
.auth-form .field label { color: var(--text); font-size: 12px; letter-spacing: 0; text-transform: uppercase; }
.auth-form input { min-height: 48px; border-color: #d6d3df; background: #fdfcff; }
.auth-form input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14); }
.auth-submit { width: 100%; min-height: 48px; }
.link-btn {
  background: none;
  border: none;
  color: var(--purple);
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  padding: 10px;
  font-size: 14px;
}
.auth-account-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.auth-account-actions .link-btn {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  font-size: 12px;
  line-height: 1.25;
}
.auth-account-actions .link-btn:hover { border-color: var(--purple); background: var(--purple-light); }
.forgot-password-btn { margin-top: 4px; color: var(--purple-dark); text-decoration: underline; text-underline-offset: 3px; }
.auth-return-login { margin-top: 12px; }
.error-msg {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  margin: -6px 0 12px;
  min-height: 16px;
}
.reset-token-panel {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
}
.reset-token-row { display: flex; align-items: center; gap: 8px; }
.reset-token-row code { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-size: 12px; }
.reset-token-row .btn { width: auto; margin: 0; white-space: nowrap; }
.reset-token-panel p { margin: 0; }

/* Progress bar (onboarding steps) */
.step-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.step-progress span {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
}
.step-progress span.done { background: var(--purple); }

/* Grid selection (levels, languages) */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  padding: 12px 6px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  background: var(--bg-soft);
}
.chip.selected { border-color: var(--purple); background: var(--purple-light); color: var(--purple); }

/* Course view */
.lesson-card { cursor: pointer; }
.lesson-title { font-weight: 700; font-size: 16px; }
.lesson-meta { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  background: var(--green);
  color: #fff;
}
.badge.level { background: var(--purple); }
.vocab-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.vocab-item:last-child { border-bottom: none; }
.exercise-block { margin-bottom: 16px; padding: 12px; background: var(--bg-soft); border-radius: var(--radius-md); }
.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-top: 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
}
.option-btn.correct { border-color: var(--green); background: #ecfdf5; }
.option-btn.incorrect { border-color: var(--danger); background: #fef2f2; }

/* Rating */
.leader-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.leader-row:last-child { border-bottom: none; }
.leader-rank { font-weight: 800; color: var(--purple); width: 26px; }
.leader-name { flex: 1; font-weight: 600; }
.leader-identity { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.leader-email { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-xp { font-weight: 800; color: var(--green-dark); }
.rating-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.rating-period-tabs { display: flex; gap: 6px; }
.rating-period-tab {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}
.rating-period-tab:hover { border-color: #9bb49b; }
.rating-period-tab.selected { border-color: var(--purple); background: var(--purple-light); color: var(--purple-dark); }
.rating-select-row { display: flex; gap: 10px; }
.rating-select { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rating-select span { color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.rating-select select,
.rating-select input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.rating-select select:focus,
.rating-select input:focus { border-color: var(--green); outline: 0; box-shadow: 0 0 0 3px rgba(88, 133, 106, 0.14); }
.partner-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
.partner-filter { flex: 1 1 30%; display: flex; flex-direction: column; gap: 4px; min-width: 90px; }
.partner-filter span { color: var(--purple); font-size: 11px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; }
.partner-filter select { min-width: 0; }

/* Games */
.game-card { text-align: center; }
.game-emoji { font-size: 40px; margin-bottom: 8px; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.match-cell {
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  background: var(--bg-soft);
}
.match-cell.selected { border-color: var(--purple); }
.match-cell.matched { border-color: var(--green); background: #ecfdf5; opacity: 0.6; pointer-events: none; }

/* Profile */
.profile-header { display: flex; flex-direction: column; align-items: center; padding: 20px 0; }
.profile-hub { display: grid; gap: 18px; max-width: 880px; margin: 0 auto; }
.profile-hero { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 22px; border: 1px solid #bfdcc6; border-bottom: 5px solid #5a9d69; border-radius: 8px; background: linear-gradient(135deg, #eff8ec, #fffdf3); }
.profile-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.profile-avatar { display: grid; flex: 0 0 68px; width: 68px; height: 68px; place-items: center; border: 3px solid #fff; border-radius: 50%; background: #306f49; box-shadow: 0 3px 0 #22573a; color: #fff; font-size: 25px; font-weight: 800; }
.profile-identity p, .profile-section-heading p { margin: 0 0 3px; color: var(--green-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.profile-identity h1 { margin: 0; font-size: 26px; overflow-wrap: anywhere; }
.profile-identity span { display: block; margin-top: 4px; overflow-wrap: anywhere; color: var(--text-muted); font-size: 13px; }
.profile-edit-btn { align-self: start; width: auto; margin: 0; }
.profile-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; }
.profile-meta span { padding: 5px 8px; border: 1px solid #c7ddca; border-radius: 4px; background: rgba(255, 255, 255, .65); color: #476551; font-size: 11px; font-weight: 700; }
.profile-scoreboard { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.profile-scoreboard div { display: grid; gap: 4px; padding: 13px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); text-align: center; }
.profile-scoreboard strong { overflow-wrap: anywhere; color: var(--green-dark); font-size: 19px; }
.profile-scoreboard span { color: var(--text-muted); font-size: 11px; font-weight: 700; }
.profile-weekly { padding: 17px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-soft); }
.profile-weekly > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-weekly p { margin: 0; color: var(--text-muted); font-size: 12px; }
.profile-weekly h2 { margin: 0; font-size: 18px; }
.profile-weekly strong { color: var(--green-dark); font-size: 21px; }
.profile-progress-track { height: 9px; margin: 12px 0 9px; overflow: hidden; border-radius: 99px; background: #dbe7d7; }
.profile-progress-track i { display: block; height: 100%; border-radius: inherit; background: #5ca866; }
.profile-section { padding-top: 2px; }
.profile-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.profile-section-heading h2 { margin: 0; font-size: 19px; }
.profile-section-heading > span { display: grid; min-width: 26px; height: 26px; place-items: center; border-radius: 50%; background: var(--bg-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.profile-course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.profile-course-card { padding: 14px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.profile-course-card > div, .profile-course-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.profile-course-card > div span { min-width: 0; overflow-wrap: anywhere; font-weight: 800; }
.profile-course-card > div strong { padding: 4px 6px; border-radius: 4px; background: #e8f4e5; color: var(--green-dark); font-size: 11px; }
.profile-course-card p { min-height: 34px; margin: 9px 0; color: var(--text-muted); font-size: 12px; }
.profile-course-card footer { padding-top: 9px; border-top: 1px solid var(--border); color: var(--green-dark); font-size: 12px; font-weight: 700; }
.profile-achievements { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.profile-achievements article { display: grid; justify-items: center; gap: 6px; min-height: 96px; padding: 12px 8px; border: 1px solid #e7db9c; border-radius: 7px; background: #fffdf2; text-align: center; }
.profile-achievements span { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: #f2c94c; color: #77570b; }
.profile-achievements strong { overflow-wrap: anywhere; font-size: 11px; }
.profile-notification { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.profile-notification:first-of-type { border-top: 0; }
.profile-notification p { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.profile-notification .btn { width: auto; margin: 0; flex-shrink: 0; }
.profile-empty { margin: 0; color: var(--text-muted); font-size: 13px; }
.lang-pair-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.lang-pair-row:last-child { border-bottom: none; }
.profile-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.profile-settings-field { display: grid; gap: 6px; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.profile-settings-save { margin-top: 14px; }
.nav-item .notification-badge { top: 5px; right: 8px; }
.settings-modal-content { width: min(720px, 100%); max-height: min(92dvh, 900px); display: flex; flex-direction: column; overflow: hidden; }
.settings-modal-body { overflow-y: auto; padding: 0 4px 10px; }
.settings-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings-section h4 { margin: 0 0 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-grid label, .settings-modal-body > label, .settings-course-row label { display: grid; gap: 6px; min-width: 0; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.settings-grid > button { grid-column: 1 / -1; width: 100%; }
.settings-save-profile { width: 100%; }
.settings-course-list { display: grid; gap: 10px; margin: 12px 0; }
.settings-course-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 4px; }
.settings-course-row .btn { width: 100%; }
.settings-course-name { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.settings-course-name span { color: var(--text-muted); font-size: 12px; }
.settings-add-course { margin-top: 12px; }
.settings-add-course summary { padding: 10px 0; color: var(--green-dark); font-weight: 700; cursor: pointer; }
.settings-menu { display: grid; gap: 9px; }
.settings-menu-btn { width: 100%; min-height: 46px; justify-content: flex-start; text-align: left; }
.settings-actions { display: grid; gap: 9px; padding-top: 14px; }
.settings-actions .btn { width: 100%; }
.course-action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; margin: 14px 0 4px; }
.course-progress-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 8px; font-size: 13px; }
.daily-lesson-hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(180px, .8fr); gap: 18px; padding: 22px; border: 1px solid #81c795; border-bottom: 5px solid #398a50; border-radius: 8px; background: linear-gradient(135deg, #effbe8, #fffceb); }
.daily-lesson-copy h1 { margin: 3px 0 7px; font-size: 29px; color: #1d5131; }
.daily-lesson-copy p:not(.daily-lesson-eyebrow) { margin: 0; color: #43614b; }
.daily-lesson-eyebrow { margin: 0; color: #277342; font-size: 11px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
.daily-lesson-cta { width: auto; min-width: 190px; margin-top: 16px; }
.daily-lesson-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-self: start; gap: 7px; }
.daily-lesson-stats div { display: grid; gap: 3px; min-width: 0; padding: 10px 7px; border: 1px solid #c9e7bc; border-radius: 6px; background: rgba(255, 255, 255, .7); text-align: center; }
.daily-lesson-stats strong { overflow-wrap: anywhere; font-size: 18px; color: #225f37; }
.daily-lesson-stats span { color: #53715b; font-size: 10px; font-weight: 700; }
.daily-lesson-progress { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; color: #41624b; font-size: 12px; font-weight: 700; }
.daily-lesson-progress > div { height: 9px; overflow: hidden; border-radius: 99px; background: #d9ead0; }
.daily-lesson-progress i { display: block; height: 100%; border-radius: inherit; background: #4caa62; }
.daily-quests { padding: 16px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.daily-quests h3 { margin: 0 0 12px; font-size: 17px; }
.daily-quest { margin-top: 10px; }
.daily-quest:first-of-type { margin-top: 0; }
.daily-quest-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.daily-quest-label strong { color: var(--green-dark); white-space: nowrap; }
.daily-quest-track { height: 7px; margin-top: 5px; overflow: hidden; border-radius: 99px; background: var(--border); }
.daily-quest-track div { height: 100%; border-radius: inherit; background: #6eab46; }
.daily-quest.is-complete .daily-quest-track div { background: var(--green); }
.daily-course-view { width: min(680px, 100%); margin: 0 auto; padding: 8px 0 24px; }
.daily-course-header { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; }
.daily-course-header p { margin: 0 0 3px; color: var(--green-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.daily-course-header h1 { margin: 0; font-size: 25px; }
.daily-course-streak { padding: 8px 10px; border-radius: 6px; background: #fff2d2; color: #a35f00; font-weight: 800; }
.daily-course-description { margin: 18px 0 20px; color: var(--text-muted); }
.daily-course-path { display: grid; gap: 14px; margin: 0 0 18px 20px; padding-left: 22px; border-left: 3px solid #dce9d7; }
.daily-path-step { position: relative; display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 12px; min-height: 74px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.daily-path-step > span { position: absolute; left: -51px; display: grid; width: 48px; height: 48px; place-items: center; border: 3px solid #dce9d7; border-radius: 50%; background: #fff; color: #7d9380; font-weight: 900; }
.daily-path-step small, .daily-path-step strong, .daily-path-step em { display: block; }
.daily-path-step small { color: var(--text-muted); font-size: 11px; font-style: normal; }
.daily-path-step strong { margin: 3px 0; color: var(--text); font-size: 16px; }
.daily-path-step em { color: var(--green-dark); font-size: 12px; font-style: normal; font-weight: 700; }
.daily-path-step.is-done > span { border-color: var(--green); background: var(--green); color: #fff; }
.daily-path-step.is-current { border-color: #75bd75; border-bottom-width: 4px; background: #f1fceb; }
.daily-path-step.is-current > span { border-color: #529e55; background: #62b566; color: #fff; }
.daily-path-step.is-locked { opacity: .65; }
.daily-course-quests { display: flex; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: 7px; color: var(--text-muted); font-size: 13px; }
.daily-course-quests strong { color: var(--green-dark); }
.daily-course-start { width: 100%; margin-top: 18px; }
.curriculum-card { padding: 16px; }
.curriculum-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.curriculum-heading h3 { margin: 0; }
.curriculum-unit-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.curriculum-unit { display: grid; align-content: center; justify-items: start; gap: 4px; min-width: 0; min-height: 78px; padding: 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); text-align: left; cursor: pointer; }
.curriculum-unit strong { font-size: 17px; }
.curriculum-unit span, .curriculum-unit small { max-width: 100%; overflow-wrap: anywhere; font-size: 10px; }
.curriculum-unit.available { border-color: var(--green); background: #edf4e8; }
.curriculum-unit.completed { border-color: #b8c7ae; background: #f1f4ed; }
.curriculum-unit.locked { opacity: 0.55; cursor: not-allowed; }
.level-exam-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.level-exam-row p { margin: 5px 0 0; }
.level-exam-row .btn { flex-shrink: 0; }
.course-activity-card { margin: 14px 0; }
.device-sessions-list { display: grid; gap: 10px; }
.device-session-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; }
.device-session-card > div { display: grid; min-width: 0; gap: 4px; }
.device-session-card strong { overflow-wrap: anywhere; }
.device-session-card span { color: var(--text-muted); font-size: 12px; }
.device-session-card .btn { flex-shrink: 0; }
.conversation-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.conversation-heading h3 { margin: 0; }
.speaking-transcript { display: grid; gap: 10px; max-height: 52vh; margin: 14px 0; overflow-y: auto; }
.conversation-message { max-width: 88%; padding: 10px 12px; border-radius: 12px; overflow-wrap: anywhere; }
.conversation-message p { margin: 5px 0; }
.partner-message { justify-self: start; background: var(--bg-soft); }
.learner-message { justify-self: end; background: #edf4e8; }
.conversation-prompt { margin: 0; color: var(--text-muted); font-size: 13px; }
.conversation-feedback { margin: 0; color: var(--green-dark); font-weight: 700; }
.course-listening-item { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.course-listening-item > p { margin: 4px 0; }
.course-listening-item .option-btn { min-height: 42px; }
.model-answer { margin: 12px 0; color: var(--text-muted); }
.model-answer p { overflow-wrap: anywhere; }
.course-activity-card > .btn { width: 100%; margin-top: 8px; }
.roadmap-level { border-top: 1px solid var(--border); padding: 8px 0; }
.roadmap-level summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; cursor: pointer; }
.roadmap-lesson { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.roadmap-lesson:hover { background: var(--bg-soft); }
.roadmap-topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 7px; padding: 5px 0; }
.roadmap-topic { min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); text-align: left; cursor: pointer; }
.roadmap-topic:hover:not(:disabled) { border-color: var(--green); background: var(--bg-soft); }
.roadmap-topic:disabled { opacity: 0.5; cursor: not-allowed; }
.roadmap-empty { margin: 8px 0 4px; }
.offline-notice { padding: 10px 12px; border-left: 3px solid var(--green); background: var(--bg-soft); color: var(--text-muted); font-size: 13px; }
.vocab-practice-row { align-items: center; gap: 8px; }
.vocab-practice-row > div:first-child { display: grid; min-width: 0; gap: 4px; }
.vocab-practice-actions { display: flex; gap: 6px; flex-shrink: 0; }
.placement-form { display: grid; gap: 16px; }
.placement-question { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 4px; }
.placement-question legend { padding: 0 5px; font-weight: 700; }
.placement-option { display: flex; align-items: center; gap: 9px; margin-top: 8px; cursor: pointer; }
.placement-option input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--green); }
.review-card { text-align: center; padding: 28px 16px; }
.review-card h2 { overflow-wrap: anywhere; }
.review-answer { margin: 20px 0; padding: 14px; background: var(--bg-soft); }
.review-card button { margin: 5px; }
.certificate-panel { display: grid; justify-items: center; gap: 12px; max-width: 760px; margin: 24px auto; padding: clamp(24px, 5vw, 56px); border: 2px solid var(--green); background: #fffefa; text-align: center; }
.certificate-panel h1 { color: var(--green-dark); }
.certificate-panel h2 { font-size: 28px; overflow-wrap: anywhere; }
.certificate-brand { color: var(--green-dark); font-weight: 800; }
.skill-meter-track { height: 8px; overflow: hidden; border-radius: 4px; background: var(--border); }
.skill-meter-fill { height: 100%; border-radius: inherit; background: var(--green); }

@media print {
  body * { visibility: hidden !important; }
  .certificate-panel, .certificate-panel * { visibility: visible !important; }
  .certificate-panel { position: absolute; inset: 0; max-width: none; margin: 0; border: 2px solid #245d4d; }
  .no-print { display: none !important; }
}

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg); width: min(560px, 100%);
  border-radius: 20px 20px 0 0; padding: 20px;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 30px;
  font-size: 14px; font-weight: 600; z-index: 200; max-width: 90%; text-align: center;
}
.toast.hidden { display: none; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--green-dark); }

/* Back to top floating button */
.back-to-top {
  position: fixed; z-index: 45;
  right: 26px; bottom: 26px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--purple); color: #fffefa;
  font-size: 22px; line-height: 1; cursor: pointer;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.22);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(0.9);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease, background-color 160ms ease;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.back-to-top:hover { background: var(--purple-dark); }
.back-to-top:active { transform: translateY(1px) scale(0.97); }
.back-to-top:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 16px; }
.empty-state .emoji { font-size: 40px; margin-bottom: 10px; }

/* Search */
.view-header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.view-header-row h1 { margin: 0; }
.search-toggle-btn {
  background: var(--purple-light); border: none; border-radius: 50%;
  width: 38px; height: 38px; font-size: 16px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--purple);
}
.search-bar { margin: 10px 0 14px; }
.search-bar.hidden { display: none; }
.search-no-results { text-align: center; color: var(--text-muted); padding: 20px; font-size: 14px; }

.spinner {
  border: 3px solid var(--purple-light);
  border-top: 3px solid var(--purple);
  border-radius: 50%;
  width: 28px; height: 28px;
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Lingolion visual system */
:root {
  --purple: #235c45;
  --purple-dark: #174631;
  --purple-light: #e1eee6;
  --green: #a7c957;
  --green-dark: #396b43;
  --bg: #fffefa;
  --bg-soft: #f3f4ed;
  --text: #1d2f29;
  --text-muted: #687870;
  --border: #dce3d9;
  --danger: #bd5143;
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
  --shadow: 0 16px 42px rgba(27, 53, 39, 0.09);
  --nav-height: 72px;
  --header-height: 76px;
  --coral: #e77d5d;
  --sidebar-width: 248px;
}

html,
body {
  min-width: 320px;
  background: #eef0e8;
  color: var(--text);
  font-family: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button { color: inherit; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.chip:focus-visible {
  outline: 3px solid rgba(231, 125, 93, 0.55);
  outline-offset: 2px;
}

#app {
  background: var(--bg-soft);
}

.app-header {
  position: fixed;
  z-index: 25;
  inset: 0 0 auto var(--sidebar-width);
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 38px;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(255, 254, 250, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.brand {
  position: fixed;
  z-index: 35;
  top: 22px;
  left: 24px;
  color: #fffefa;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 700;
}

.brand-emoji { margin-left: 3px; }

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--purple);
  transition: background-color 160ms ease, transform 160ms ease;
}

.icon-btn:hover { background: var(--purple-light); }
.install-app-btn { color: var(--purple); background: var(--purple-light); }

.bottom-nav {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  max-width: none;
  height: 100dvh;
  padding: 92px 14px 24px;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 7px;
  background: #204c3a;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 13px;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: rgba(255, 254, 250, 0.7);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.nav-item:hover {
  color: #fffefa;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  color: #fffefa;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active::before {
  position: absolute;
  inset: 9px auto 9px -15px;
  width: 3px;
  border-radius: 2px;
  background: #d8e98b;
  content: "";
}

.nav-icon {
  display: grid;
  flex: 0 0 26px;
  place-items: center;
  font-size: 19px;
}
.daily-nav-item .nav-icon { color: #d8e98b; }
.daily-nav-item.active .nav-icon { color: inherit; }

.nav-label {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-view {
  min-height: calc(100dvh - var(--header-height));
  margin: var(--header-height) 0 0 var(--sidebar-width);
  padding: 34px clamp(24px, 4vw, 64px) 64px;
  overflow-y: auto;
  background-color: var(--bg-soft);
  background-image: linear-gradient(rgba(45, 79, 58, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(45, 79, 58, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  animation: fadeIn 220ms ease both;
}

.main-view > * {
  width: min(100%, 1040px);
  margin-right: auto;
  margin-left: auto;
}

.main-view h1,
.main-view h2,
.main-view h3 {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

.main-view h1 {
  margin: 0 0 22px;
  font-size: clamp(27px, 3vw, 36px);
  line-height: 1.15;
}

.main-view h2 { font-size: 25px; }
.main-view h3 { margin-top: 0; font-size: 19px; }

.view-header-row {
  min-height: 54px;
  margin-bottom: 20px;
}

.view-header-row h1 { margin: 0; }

.card {
  margin: 0 0 16px;
  padding: clamp(18px, 2.4vw, 26px);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  box-shadow: 0 5px 18px rgba(27, 53, 39, 0.035);
}

.card > :last-child { margin-bottom: 0; }
.lesson-card { transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
.lesson-card:hover { transform: translateY(-2px); border-color: #9ab8a1; box-shadow: var(--shadow); }
.lesson-title { font-size: 17px; }
.lesson-meta { color: var(--text-muted); }

.btn {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: wait; opacity: 0.62; transform: none; }
.btn-primary { background: var(--purple); color: #fffefa; }
.btn-primary:hover { background: var(--purple-dark); }
.btn-secondary { background: #e3ebd5; color: #334f32; }
.btn-secondary:hover { background: #d6e2c2; }
.btn-outline { border-color: var(--border); background: transparent; color: var(--purple); }
.btn-outline:hover { border-color: var(--purple); background: var(--purple-light); }
.btn-danger { background: #fae8e3; color: #9c382d; }

.field { margin-bottom: 16px; }
.field label,
.onboarding-screen > form > label,
.modal-body > label {
  display: block;
  margin-bottom: 7px;
  color: #43564d;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cfd9cf;
  border-radius: 4px;
  background: #fffefa;
  color: var(--text);
  font-size: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input::placeholder,
textarea::placeholder { color: #87938a; opacity: 1; }
input:focus,
select:focus,
textarea:focus { border-color: #58856a; outline: 0; box-shadow: 0 0 0 3px rgba(88, 133, 106, 0.14); }
textarea { min-height: 110px; }

.badge {
  padding: 4px 9px;
  border-radius: 3px;
  background: #e5edda;
  color: #3a603d;
}

.badge.level { background: #e2eee5; color: #28583f; }

.exercise-block { padding: 16px; border: 1px solid var(--border); border-radius: 5px; background: #f7f8f2; }
.option-btn { border-width: 1px; border-radius: 4px; background: #fffefa; }
.option-btn:hover { border-color: #8fab92; background: #f6f8f1; }
.option-btn.correct { border-color: var(--green-dark); background: #e9f1df; }
.option-btn.incorrect { border-color: var(--danger); background: #fae8e3; }

.chip-grid { gap: 9px; }
.chip {
  min-height: 44px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fffefa;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}
.chip:hover { border-color: #9bb49b; }
.chip.selected { border-color: var(--purple); background: var(--purple-light); color: var(--purple-dark); }
.step-progress span { height: 6px; border-radius: 2px; }
.step-progress span.done { background: var(--coral); }

#app:has(.auth-screen) .app-header { left: 0; }
#app:has(.auth-screen) .main-view {
  display: grid;
  min-height: calc(100dvh - var(--header-height));
  margin-left: 0;
  padding: 28px;
  place-items: center;
}

.onboarding-screen {
  width: min(100%, 760px);
  min-height: auto;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.onboarding-screen h2 { margin: 0 0 24px; }
.onboarding-screen form > .btn { min-width: 150px; }

.leader-row { gap: 16px; padding: 14px 4px; border-color: #e7ebe3; }
.leader-row:first-child .leader-rank { color: var(--coral); }
.leader-xp { color: var(--green-dark); }
.search-toggle-btn { border: 1px solid var(--border); border-radius: 5px; background: #fffefa; color: var(--purple); }
.search-toggle-btn:hover { background: var(--purple-light); }
.search-bar { margin: 0 0 16px; }
.empty-state { padding: 46px 18px; }
.empty-state .emoji { margin-bottom: 14px; }

.profile-header { padding: 10px 0 20px; }

.game-card { min-height: 190px; border-top: 3px solid var(--green); }
.game-card:nth-child(2) { border-top-color: var(--coral); }
.game-card:nth-child(3) { border-top-color: #c8d866; }
.translator-card { border-top-color: var(--coral); }
.translator-card .game-emoji { background: #faede6; color: #9a4b35; }
.google-translate-card { border-top-color: var(--green-dark); }
.google-translate-card .game-emoji { background: #e8f0df; color: var(--green-dark); }
.game-emoji { display: grid; width: 58px; height: 58px; margin: 0 auto 16px; place-items: center; border-radius: 50%; background: #edf2e5; }
.match-cell { border-width: 1px; border-radius: 4px; background: #fffefa; }
.match-cell:hover { border-color: #90ad91; }
.match-cell.selected { border-color: var(--coral); background: #fbede8; }
.match-cell.matched { border-color: var(--green-dark); background: #e9f1df; }

.wa-chat-screen {
  border-color: var(--border);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(24, 55, 39, 0.24);
}
/* Desktop: the chat floats above the sidebar, brand and back-to-top button.
   On mobile (<=700px) the rule below drops it below the bottom nav (z-30) so
   the app's main navigation stays visible while chatting — the chat screen
   ends above the nav, so nothing overlaps there. */
.main-view:has(.wa-chat-screen) { position: relative; z-index: 46; }
#app:has(.wa-chat-screen) .back-to-top { display: none; }
/* ---- ДИЗАЙНИ АКАДЕМИКИИ РАВЗАНАИ ЧАТ (COMMUNICATION) ----
   Navy + gold academic palette shared with the auth window: paper
   backgrounds, Georgia serif headings, thin borders and uppercase labels. */
.communication-heading { min-height: 46px; margin-bottom: 2px; }
.communication-heading h1 { font-family: Georgia, "Times New Roman", serif; color: var(--purple-dark); letter-spacing: 0.2px; }
.communication-heading-mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--coral); border-radius: 50%; background: #fdf6e3; color: #97791a; font-size: 18px; }
.communication-subtitle { margin: 0 0 18px; color: var(--text-muted); font-size: 13px; line-height: 1.5; font-style: italic; }
.communication-search { display: flex; align-items: center; gap: 9px; margin: 0 0 22px; padding: 0 13px; border: 1px solid #d6dbe6; border-radius: 6px; background: #ffffff; color: var(--purple); box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04); }
.communication-search:focus-within { border-color: var(--purple-dark); outline: 3px solid rgba(27, 42, 74, 0.12); }
.communication-search > span { font-size: 23px; line-height: 1; }
.communication-search input { width: 100%; min-width: 0; min-height: 46px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.communication-search input:focus { outline: 0; }
.communication-search input::-webkit-search-cancel-button { cursor: pointer; }
.communication-sections { display: grid; gap: 21px; }
.communication-section .wa-list-header { padding: 0 2px 8px; }
.communication-section .wa-list-header h2 { color: var(--purple); font-family: Georgia, serif; font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; }
.communication-section .wa-chat-list { overflow: hidden; border: 1px solid #d9dee8; border-radius: 7px; background: #ffffff; box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05); }
.communication-section .wa-list-item { min-height: 75px; padding: 12px 14px; border-bottom-color: #eceff5; }
.communication-section .wa-list-item:last-child { border-bottom: 0; }
.communication-section .wa-list-item:hover, .communication-section .wa-list-item:focus-visible { background: #f5f7fc; }
.communication-section .wa-list-item:focus-visible { outline: 2px solid var(--purple-dark); outline-offset: -3px; }
.communication-section .wa-avatar { width: 46px; height: 46px; border: 1px solid #d5dbe7; border-radius: 50%; background: #eef1f7; color: var(--purple); }
.communication-section .ai-avatar { border-color: var(--purple-dark); background: var(--purple-dark); color: var(--coral); }
.communication-section .partner-avatar { border-color: #e6d5a9; background: #fdf6e3; color: #8a6d1f; }
.communication-section .wa-list-name { color: var(--purple-dark); font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-weight: 700; }
.communication-section .wa-list-preview { color: #6b7688; }
.communication-section .wa-list-email { color: #7d8798; }
.wa-list-arrow { color: var(--coral); font-size: 23px; line-height: 1; }
.communication-no-results { margin: 0; padding: 26px 14px; border: 1px dashed #c6cdda; border-radius: 6px; color: var(--text-muted); text-align: center; font-size: 13px; font-style: italic; }
.communication-no-results.hidden { display: none; }
.communication-notifications { margin: 14px 0 20px; padding: 14px; border: 1px solid #e6e0cb; border-left: 3px solid var(--coral); background: #fdfaf0; }
.communication-notifications h2 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 16px; color: var(--purple-dark); }
.communication-notification { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #ece6d2; }
.communication-notification p { margin: 4px 0 0; overflow-wrap: anywhere; color: var(--text-muted); font-size: 13px; }
.communication-notification .btn { flex-shrink: 0; }
/* Chat screen: navy academic header over a graph-paper message area. */
.wa-header { min-height: 76px; background: linear-gradient(180deg, #16233f 0%, var(--purple-dark) 100%); border-bottom: 3px solid var(--coral); }
.wa-header-name { color: #fff; font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: 0.2px; }
.wa-header-status { color: #aab6cf; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.wa-header-email { color: #e6d5a9; font-size: 11px; letter-spacing: 0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-header .wa-avatar { border: 1px solid rgba(197, 155, 39, 0.55); background: rgba(197, 155, 39, 0.14); color: var(--coral); }
.wa-back-btn, .wa-menu-btn, .wa-call-btn { border: 1px solid rgba(197, 155, 39, 0.5); background: rgba(255, 255, 255, 0.07); color: #f2e7c9; }
.wa-back-btn:hover, .wa-menu-btn:hover, .wa-call-btn:hover { border-color: var(--coral); background: rgba(197, 155, 39, 0.22); color: #fff; }
.wa-chat-bg { padding-top: 24px; padding-bottom: 24px; background-color: #f6f5ed; background-image: linear-gradient(rgba(27, 42, 74, 0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(27, 42, 74, 0.045) 1px, transparent 1px); background-size: 26px 26px; scrollbar-color: #c9cfd9 transparent; }
.wa-date-sep { border: 1px solid #ddd8c4; background: #fffefa; color: var(--purple); font-size: 10px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04); }
.msg { max-width: min(74%, 600px); padding: 12px 15px 29px; border: 1px solid #dcdfe8; border-radius: 7px; background: #fff; color: #27303f; line-height: 1.6; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05); }
.msg.mine { border-color: var(--purple); background: var(--purple); color: #fff; }
.msg.ai { border-left: 3px solid var(--coral); background: #fffefa; }
.msg .correction { border-top-color: rgba(15, 23, 42, 0.12); color: #59617a; font-style: italic; }
.msg .correction strong { color: var(--purple); }
.msg.mine .correction { border-top-color: rgba(255, 255, 255, 0.28); color: #ccd5ea; }
.msg.mine .correction strong { color: var(--coral); }
.msg-time { color: #8b93a5; }
.msg.mine .msg-time { color: #b7c3e0; }
.msg-ticks { color: var(--coral); }
.msg-delete-btn { color: #8b93a5; }
.msg.mine .msg-delete-btn { color: #b7c3e0; }
.msg-delete-btn:hover { background: rgba(15, 23, 42, 0.1); color: var(--danger); }
.wa-typing-dot { background: var(--purple); }
.wa-composer { border-top: 1px solid #dfe3ec; background: #fffefa; box-shadow: 0 -8px 22px rgba(15, 23, 42, 0.06); }
.composer-attachment { border: 1px solid #e0dccd; background: #fdfaf1; }
.composer-attachment-name { color: var(--purple); }
.composer-attachment-remove { background: rgba(15, 23, 42, 0.8); }
.composer-attachment-remove:hover { background: var(--danger); }
.wa-input-row { gap: 9px; background: #fffefa; }
.wa-input-row input, .wa-input-row textarea { border: 1px solid #d3d8e3; background: #fff; color: var(--text); }
.wa-input-row input:focus, .wa-input-row textarea:focus { border-color: var(--purple-dark); background: #fff; box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.12); outline: 0; }
.wa-input-row textarea { border-radius: 5px; }
.wa-attach-btn, .wa-send-btn, .wa-voice-message-btn { width: 42px; height: 42px; border-radius: 5px; }
.ai-practice-tools { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #e2e6ef; background: #fffefa; }
.ai-practice-tools label { color: var(--purple); font-size: 11px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; }
.ai-practice-select { min-width: 0; padding: 7px 10px; border: 1px solid #d3d8e3; border-radius: 5px; background: #fff; color: var(--text); font: inherit; font-size: 13px; }
.ai-practice-select:focus { border-color: var(--purple-dark); outline: 0; box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.12); }
.msg-speak-btn { display: inline-grid; width: 30px; height: 28px; place-items: center; margin: 6px 8px 0 0; border: 1px solid #d9d3bf; border-radius: 5px; background: #fffefa; color: var(--purple); cursor: pointer; }
.msg-speak-btn:hover { border-color: var(--coral); background: #fdf6e3; color: var(--purple-dark); }
.ai-speech-input-btn.recording { border-color: #b34a3f; background: #fdf0ee; color: var(--danger); }
.wa-attach-btn, .wa-voice-message-btn { border: 1px solid #d3d8e3; background: #fff; color: var(--purple); }
.wa-attach-btn:hover, .wa-voice-message-btn:hover { border-color: var(--coral); background: #fdf6e3; color: var(--purple-dark); }
.wa-send-btn { border-color: var(--purple-dark); background: var(--purple-dark); color: var(--coral); box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25); }
.wa-send-btn:hover { border-color: var(--coral); background: var(--coral); color: var(--purple-dark); }
.wa-back-btn:focus-visible, .wa-menu-btn:focus-visible, .wa-call-btn:focus-visible,
.wa-attach-btn:focus-visible, .wa-send-btn:focus-visible, .wa-voice-message-btn:focus-visible,
.msg-speak-btn:focus-visible, .msg-delete-btn:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.voice-call-panel { border-bottom: 1px solid #e6e0cb; background: #f9f5e8; color: var(--purple-dark); }
.voice-call-actions button { border: 1px solid #cdd3e0; background: #fff; color: var(--purple-dark); }
.voice-call-actions .call-accept-btn { border-color: var(--purple-dark); background: var(--purple-dark); color: var(--coral); }
.voice-call-actions .call-end-btn { border-color: var(--danger); background: var(--danger); color: #fff; }

.msg-sender { display: block; margin-bottom: 4px; color: #97791a; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.msg.mine .msg-sender { color: var(--coral); }
.wa-chat-bg { min-height: 0; }

.space-form-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* Install-help dialog (PWA fallback when no native prompt is available) */
.install-help-content { border-top: 4px solid var(--purple-dark); }
.install-help-body { display: grid; gap: 14px; justify-items: center; padding: 4px 4px 10px; text-align: center; }
.install-help-icon { display: grid; width: 64px; height: 64px; place-items: center; border: 2px solid var(--coral); border-radius: 50%; background: var(--purple-dark); color: var(--coral); font-size: 28px; box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2); }
.install-help-message { margin: 0; color: var(--text); font-size: 14px; line-height: 1.65; }

/* Rating: language-pair selector (per-pair leaderboard) */
.rating-pair-field { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.rating-pair-field > span { color: var(--purple); font-size: 11px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; white-space: nowrap; }
.rating-pair-select { flex: 1; min-width: 0; min-height: 40px; padding: 8px 12px; border: 1px solid #d6dbe6; border-radius: 5px; background: #fff; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.rating-pair-select:focus { border-color: var(--purple-dark); outline: 0; box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.12); }
.rating-pair-context { margin: 6px 0 0; color: var(--text-muted); font-size: 12px; font-style: italic; }

/* Admin: rankings of every learning language */
.admin-ratings-section { margin-top: 22px; }
.admin-ratings-filter { display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.admin-ratings-filter select { min-height: 38px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.admin-ratings-filter select:focus { border-color: var(--purple-dark); outline: 0; box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.12); }
.admin-ratings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-top: 14px; }
.admin-rating-card { overflow: hidden; border: 1px solid var(--border); border-top: 3px solid var(--purple-dark); border-radius: 7px; background: #fff; }
.admin-rating-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.admin-rating-card-head h3 { margin: 0; color: var(--purple-dark); font-family: Georgia, "Times New Roman", serif; font-size: 14px; }
.admin-rating-card-head span { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.admin-rating-list { max-height: 280px; margin: 0; padding: 4px 0; overflow-y: auto; list-style: none; }
.admin-rating-list li { display: flex; align-items: center; gap: 9px; padding: 7px 13px; font-size: 13px; }
.admin-rating-list li + li { border-top: 1px solid #f0f2f6; }
.admin-rating-rank { display: grid; flex-shrink: 0; width: 22px; height: 22px; place-items: center; border: 1px solid var(--border); border-radius: 50%; color: var(--purple); font-size: 10px; font-weight: 800; }
.admin-rating-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-rating-streak { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.admin-rating-list strong { color: var(--purple-dark); font-size: 12px; white-space: nowrap; }
.admin-ratings-empty { margin: 0; padding: 26px 14px; border: 1px dashed var(--border); border-radius: 6px; color: var(--text-muted); font-size: 13px; font-style: italic; text-align: center; }

.space-form-actions { position: sticky; bottom: 0; z-index: 1; margin-top: 2px; padding-top: 12px; background: var(--bg); box-shadow: 0 -10px 14px -8px rgba(15, 23, 42, 0.16); }
.space-form-actions .btn { min-height: 44px; }

@media (max-width: 700px) {
  .space-form-actions .btn { flex: 1 1 0; min-width: 0; min-height: 48px; padding-left: 6px; padding-right: 6px; white-space: nowrap; }
  .space-form-actions { gap: 8px; }
}

@media (max-width: 380px) {
  /* Very narrow phones: keep both action buttons on one row. */
  .space-form-actions .btn { font-size: 13px; padding-left: 4px; padding-right: 4px; }
  .space-form-actions { gap: 6px; }
}

.modal { align-items: center; padding: 20px; background: rgba(22, 39, 31, 0.45); backdrop-filter: blur(4px); }
.modal-content { width: min(480px, 100%); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.settings-modal-content { width: min(720px, 100%); }
.toast { bottom: 22px; border-radius: 5px; box-shadow: 0 8px 28px rgba(19, 37, 28, 0.2); }
.toast.error { background: #a83c31; }
.toast.success { background: #396b43; }
.spinner { border-color: #dce8dd; border-top-color: var(--coral); }

.games-heading { align-items: center; }
.translate-btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; white-space: nowrap; }
.translate-btn span:first-child { font-size: 18px; line-height: 1; }
.games-pair-label { display: block; margin: 0 0 6px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.games-pair-select { max-width: 420px; margin: 0 0 16px; }
.books-library { display: grid; gap: 16px; }
.books-library-intro { margin: 0; color: var(--text-muted); line-height: 1.55; }
.books-library-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.book-level-card { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-soft); }
.book-level-card.is-ready { border-color: #98c99a; background: #f0faed; }
.book-level-badge { display: grid; width: 42px; height: 48px; place-items: center; border-radius: 4px 8px 8px 4px; background: #376b48; box-shadow: inset -4px 0 rgba(0, 0, 0, .12); color: #fff; font-size: 13px; font-weight: 800; }
.book-level-card h3 { margin: 2px 0 4px; font-size: 16px; }
.book-level-card p { margin: 0; color: var(--text-muted); font-size: 12px; }
.book-level-card .btn { grid-column: 1 / -1; width: 100%; margin: 2px 0 0; }
.book-file-list { grid-column: 1 / -1; display: grid; gap: 7px; }
.book-file-list .btn { min-width: 0; overflow-wrap: anywhere; text-align: center; }
.translator-panel { border-left: 4px solid var(--green); }
.translator-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.translator-panel-heading h2 { margin: 0; font-size: 23px; }
.translator-language-pair { margin: 7px 0 0; color: var(--text-muted); font-size: 13px; }
.translator-provider { flex: 0 0 auto; padding: 6px 9px; border: 1px solid var(--border); border-radius: 4px; color: var(--green-dark); font-size: 11px; font-weight: 700; }
.translator-panel form > label { display: block; margin-bottom: 7px; color: #43564d; font-size: 13px; font-weight: 700; }
.translator-panel textarea { min-height: 118px; resize: vertical; }
.translator-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.translator-limit { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.translator-note { margin: 14px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.translator-result { margin-top: 18px; padding: 16px; border: 1px solid #dce5d8; border-radius: 5px; background: #f4f7ee; }
.translator-result-label { color: var(--green-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.translator-result p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.activity-overlay { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(22, 39, 31, 0.48); backdrop-filter: blur(5px); animation: fadeIn 160ms ease both; }
.activity-window { display: flex; width: min(760px, 100%); max-height: min(780px, calc(100dvh - 48px)); flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); box-shadow: 0 28px 90px rgba(16, 39, 27, 0.28); }
.activity-window-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; min-height: 70px; padding: 12px 22px; border-bottom: 1px solid var(--border); background: #fffefa; }
.activity-window-header h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 23px; }
.activity-close { flex: 0 0 42px; font-size: 23px; }
.activity-window-body { min-height: 0; padding: clamp(18px, 3vw, 30px); overflow-y: auto; overscroll-behavior: contain; }
.activity-window-body > .card { margin-bottom: 0; }
.activity-window-body .translator-panel-heading { margin-bottom: 20px; }
.activity-language-pair { margin: 0; color: var(--text-muted); font-size: 13px; }
.translator-language-selects { display: grid; grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr); align-items: center; gap: 12px; }
.translator-language-selects .field { min-width: 0; margin-bottom: 14px; }
.translator-swap { align-self: center; margin-top: 7px; }
.translator-swap:disabled { cursor: not-allowed; opacity: 0.45; }
.translator-input-wrap { position: relative; }
.translator-input-wrap textarea { min-height: 132px; padding-right: 58px; }
.translator-mic { position: absolute; right: 10px; bottom: 10px; color: var(--purple); }
.translator-mic.recording { border-color: var(--coral); background: #fae8e3; color: #a83c31; animation: micPulse 1.2s ease-in-out infinite; }
.translator-mic:disabled { cursor: not-allowed; opacity: 0.5; }
.speech-status { min-height: 20px; margin: 7px 0 0; color: var(--text-muted); font-size: 12px; }
.translator-speak { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 5px rgba(231, 125, 93, 0.16); } }
.activity-window-body .translator-note { margin-bottom: 0; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.game-grid .game-card { display: flex; min-height: 210px; flex-direction: column; align-items: flex-start; margin: 0; }
.game-grid .game-emoji { margin: 0 0 14px; }
.game-grid .game-card h3 { min-height: 48px; margin: 0 0 14px; }
.game-grid .game-card .play-btn { width: 100%; margin-top: auto; }
.topic-category-card { border-top: 3px solid var(--coral); }
.topic-category-card .game-emoji { background: #faede6; }
.dialogue-category-card { border-top: 3px solid #c8d866; }
.dialogue-category-card .game-emoji { background: #eef2d9; color: #53633a; }
.topic-search { margin-bottom: 18px; }
.topic-search label { display: block; margin-bottom: 7px; color: #43564d; font-size: 13px; font-weight: 700; }
.topic-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.topic-result { display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 6px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; }
.topic-result:hover { background: #f4f6ee; }
.topic-result.is-locked, .topic-result.is-locked:hover { opacity: .58; cursor: not-allowed; background: transparent; }
.topic-result-title { color: var(--text); font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 700; }
.topic-result-meta { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.topic-result-arrow { color: var(--coral); font-size: 24px; text-align: center; }
.vocabulary-learning-progress { height: 7px; overflow: hidden; border-radius: 99px; background: #e7ebdf; }
.vocabulary-learning-progress span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width 180ms ease; }
.vocabulary-learning-card { display: grid; justify-items: center; gap: 16px; padding: clamp(22px, 6vw, 38px); text-align: center; }
.vocabulary-learning-card-meta { display: flex; width: 100%; justify-content: space-between; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.vocabulary-learning-word { margin: 0; font-size: clamp(32px, 8vw, 48px); overflow-wrap: anywhere; }
.vocabulary-pronunciation { width: 48px; height: 48px; border-radius: 50%; background: #edf2e5; }
.vocabulary-learning-translation { margin: 0; color: var(--green-dark); font-size: clamp(22px, 6vw, 30px); font-weight: 700; overflow-wrap: anywhere; }
.vocabulary-learning-hint { margin: 0; color: var(--text-muted); font-size: 13px; }
.vocabulary-learning-actions { display: flex; width: 100%; flex-wrap: wrap; justify-content: center; gap: 10px; }
.vocabulary-learning-summary { display: grid; justify-items: center; gap: 12px; padding: 30px 20px; text-align: center; }
.vocabulary-learning-summary h2, .vocabulary-learning-summary p { margin: 0; }
.vocabulary-learning-summary-icon { font-size: 42px; }
.topic-empty { margin: 0; padding: 26px 10px; }
.topic-back { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 22px; }
/* Row holding the back/close buttons above game and topic windows. */
.activity-back-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.activity-back-row .topic-back { margin-bottom: 0; }
.topic-detail-heading { margin-bottom: 18px; }
.topic-language-tag { display: inline-block; margin-bottom: 8px; padding: 4px 8px; border-radius: 3px; background: #e5edda; color: var(--green-dark); font-size: 11px; font-weight: 800; }
.topic-detail-heading h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 26px; }
.topic-title-translation { margin: 5px 0 0; color: var(--text-muted); font-size: 14px; }
.topic-passage-list { display: grid; gap: 12px; max-width: 72ch; }
.topic-passage-pair { padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; background: #f5f6ef; }
.topic-passage { margin: 0; color: var(--text); line-height: 1.8; overflow-wrap: anywhere; }
.topic-passage-translation, .dialogue-line-translation { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.dialogue-transcript { display: grid; gap: 12px; margin-bottom: 20px; }
.dialogue-line { display: grid; justify-items: start; gap: 4px; max-width: min(86%, 560px); }
.dialogue-line-right { justify-self: end; justify-items: end; text-align: right; }
.dialogue-speaker { color: var(--text-muted); font-size: 11px; font-weight: 700; }
.dialogue-line p { margin: 0; padding: 11px 14px; border: 1px solid var(--border); border-radius: 6px; background: #f5f6ef; line-height: 1.6; overflow-wrap: anywhere; }
.dialogue-line-right p { border-color: #d5e2cf; background: #eaf1e4; }
.dialogue-line .dialogue-line-translation { padding: 0 6px; border: 0; background: transparent; }
.game-round { margin-top: 14px; }
.game-round .option-btn { min-height: 46px; }
.listening-play { width: 100%; margin: 6px 0 12px; }
.listening-transcript { margin: 10px 0 16px; color: var(--text-muted); font-size: 13px; }
.listening-transcript summary, .model-answer summary { cursor: pointer; font-weight: 700; }
.listening-transcript p, .model-answer p { color: var(--text); line-height: 1.6; }
.reading-passage { margin: 0 0 18px; padding: 14px; border-left: 3px solid var(--green); background: var(--bg-soft); line-height: 1.75; overflow-wrap: anywhere; }
.reading-question, .open-answer-prompt { font-weight: 700; line-height: 1.6; overflow-wrap: anywhere; }
.open-answer-round textarea { margin: 8px 0 12px; }
.open-answer-round form > button, .open-answer-round > .btn { width: 100%; margin: 6px 0; }
.game-result { text-align: center; padding: 28px; }
.game-round .scramble-word { margin: 0 0 18px; color: var(--purple-dark); font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 700; letter-spacing: 0; text-align: center; }
.game-round .game-hint { margin: 0 0 12px; color: var(--text-muted); text-align: center; }
.game-round .game-feedback { min-height: 24px; margin: 10px 0 0; font-weight: 700; }
.game-round .game-feedback.correct { color: var(--green-dark); }
.game-round .game-feedback.incorrect { color: var(--danger); }

@media (max-width: 900px) and (min-width: 701px) {
  :root { --sidebar-width: 78px; }
  .brand { left: 18px; width: 42px; overflow: hidden; font-size: 0; white-space: nowrap; }
  .brand-emoji { font-size: 22px; }
  .bottom-nav { padding-right: 10px; padding-left: 10px; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item.active::before { left: -11px; }
  .nav-label { display: none; }
  .main-view { padding-right: 28px; padding-left: 28px; }
}

.speaking-studio { display: grid; max-width: 1120px; gap: 22px; margin: 0 auto; padding-bottom: 20px; }
.speaking-hero { position: relative; display: flex; min-height: 210px; align-items: center; justify-content: space-between; gap: 24px; overflow: hidden; padding: clamp(22px, 4vw, 38px); border: 1px solid #dfe9dc; border-radius: 14px; background: radial-gradient(circle at 82% 20%, rgba(219, 235, 205, .78), transparent 32%), linear-gradient(120deg, #f3f8ed 0%, #fbfcf8 62%, #f8f4ec 100%); }
.speaking-hero-copy { position: relative; z-index: 1; max-width: 640px; }
.speaking-kicker { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; color: #52805a; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.speaking-kicker > span:first-child { color: #cf8c55; font-size: 15px; }
.speaking-hero h1 { margin: 0; color: #203b2b; font-size: clamp(25px, 4vw, 36px); letter-spacing: -.035em; line-height: 1.12; }
.speaking-hero-description { max-width: 500px; margin: 10px 0 16px; color: #68766b; font-size: 13px; line-height: 1.6; }
.speaking-pair-picker { display: inline-grid; min-width: min(280px, 100%); gap: 5px; color: #637166; font-size: 10px; font-weight: 700; }
.speaking-pair-picker select { min-height: 38px; padding: 0 32px 0 11px; border: 1px solid #dbe5d9; border-radius: 7px; background: rgba(255,255,255,.86); color: #34493a; font: inherit; font-size: 12px; }
.speaking-hero-art { position: relative; display: grid; width: 175px; height: 145px; flex: 0 0 auto; place-items: center; }
.speaking-hero-mic { position: relative; z-index: 1; display: grid; width: 80px; height: 80px; place-items: center; border: 1px solid rgba(77, 122, 80, .16); border-radius: 50%; background: linear-gradient(145deg, #fff, #e7f0df); box-shadow: 0 12px 30px rgba(55, 94, 59, .12); font-size: 35px; }
.speaking-orbit { position: absolute; border: 1px solid rgba(101, 145, 99, .2); border-radius: 50%; }
.orbit-one { width: 126px; height: 126px; }
.orbit-two { width: 164px; height: 164px; }
.speaking-bubble { position: absolute; z-index: 2; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(46, 75, 50, .11); }
.bubble-one { top: 4px; right: 2px; min-width: 54px; height: 31px; padding: 0 9px; border: 1px solid #e3eade; border-radius: 14px 14px 4px 14px; background: #fff; color: #56805a; font-size: 10px; font-weight: 700; }
.bubble-two { bottom: 0; left: 0; width: 30px; height: 30px; border-radius: 50%; background: #dcf0db; color: #397746; font-size: 14px; font-weight: 800; }
.speaking-progress-panel { padding: 17px 20px; border: 1px solid #e4eae2; border-radius: 10px; background: #fff; box-shadow: 0 4px 16px rgba(32, 57, 39, .035); }
.speaking-progress-copy { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.speaking-progress-copy p { margin: 0 0 4px; color: #78857a; font-size: 10px; font-weight: 700; }
.speaking-progress-copy strong { color: #2b4031; font-size: 18px; }
.speaking-progress-copy strong span { color: #89938a; font-size: 11px; font-weight: 500; }
.speaking-progress-percent { color: #4f8056; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.speaking-progress-track { height: 7px; overflow: hidden; margin-top: 12px; border-radius: 10px; background: #edf1eb; }
.speaking-progress-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #588a5e, #a3c46d); transition: width .3s ease; }
.speaking-progress-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: #8a958b; font-size: 9px; }
.speaking-level-list { display: grid; gap: 14px; }
.speaking-level-section { padding: 16px; border: 1px solid #e6ebe4; border-radius: 10px; background: #fff; }
.speaking-level-section.is-current { border-color: #d5e4d2; box-shadow: 0 4px 15px rgba(47, 88, 50, .04); }
.speaking-level-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; }
.speaking-level-badge { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; border: 1px solid #dfe9da; border-radius: 10px; background: #eff5e9; color: #47734b; font-size: 11px; font-weight: 850; }
.speaking-level-heading h2 { margin: 0; color: #33483a; font-size: 14px; }
.speaking-level-heading p { margin: 3px 0 0; color: #89938a; font-size: 10px; }
.speaking-level-mark { margin-left: auto; color: #82a27d; font-size: 12px; }
.speaking-level-section.is-locked .speaking-level-badge { background: #f5f6f3; color: #8e9790; }
.speaking-lesson-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.speaking-lesson-card { display: flex; min-width: 0; min-height: 104px; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid #e7ebe5; border-radius: 8px; background: #fdfefc; color: #3e4e41; text-align: left; transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease; }
.speaking-lesson-card.available { border-color: #acc9a8; background: linear-gradient(145deg, #f3f9ef, #fff); box-shadow: 0 3px 10px rgba(70, 112, 72, .07); cursor: pointer; }
.speaking-lesson-card.completed { border-color: #e0eade; background: #fafcf8; cursor: pointer; }
.speaking-lesson-card.available:hover, .speaking-lesson-card.completed:hover { transform: translateY(-2px); box-shadow: 0 7px 15px rgba(48, 84, 51, .1); }
.speaking-lesson-card.available:focus-visible, .speaking-lesson-card.completed:focus-visible { outline: 2px solid #6d9971; outline-offset: 2px; }
.speaking-lesson-card.locked { background: #f8f9f7; color: #9aa29b; cursor: not-allowed; }
.speaking-lesson-top, .speaking-lesson-bottom { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 5px; color: #879188; font-size: 9px; }
.speaking-lesson-mark { display: grid; min-width: 19px; height: 19px; place-items: center; border-radius: 50%; background: #eff2ed; color: #8c978e; font-size: 10px; }
.speaking-lesson-card.available .speaking-lesson-mark { background: #e1efdc; color: #4b8052; }
.speaking-lesson-card.completed .speaking-lesson-mark { background: #e2f1e5; color: #3d8050; }
.speaking-lesson-card > strong { width: 100%; color: #48584b; font-size: 10px; line-height: 1.35; }
.speaking-lesson-card.locked > strong { color: #889189; }
.speaking-lesson-bottom { margin-top: auto; font-size: 9px; }
.speaking-loading { display: flex; min-height: 220px; align-items: center; justify-content: center; gap: 11px; color: #758177; font-size: 12px; }
.speaking-error, .speaking-result { display: grid; min-height: 330px; align-content: center; justify-items: center; padding: 28px; border: 1px solid #e4eae2; border-radius: 12px; background: #fff; text-align: center; }
.speaking-error > span, .speaking-result-icon { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 50%; background: #eef5e9; color: #4a8050; font-size: 24px; font-weight: 800; }
.speaking-error h2 { margin: 14px 0 5px; font-size: 18px; }
.speaking-error p, .speaking-result > p:not(.speaking-kicker) { max-width: 520px; color: #78847a; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.speaking-error .btn { width: auto; margin-top: 8px; }
.speaking-session { display: grid; width: min(760px, 100%); gap: 20px; margin: 0 auto; padding: 4px 0 22px; }
.speaking-session-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.speaking-back-btn { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: #69786b; cursor: pointer; font: inherit; font-size: 12px; }
.speaking-back-btn:hover { color: #355c3c; }
.speaking-session-language { padding: 6px 10px; border: 1px solid #e2e9df; border-radius: 20px; background: #f7faf4; color: #637363; font-size: 10px; }
.speaking-session-progress { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; align-items: center; padding: 13px 15px; border: 1px solid #e5ebe3; border-radius: 9px; background: #fff; }
.speaking-session-progress > span { overflow: hidden; color: #7d897f; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.speaking-session-progress > strong { color: #4d7851; font-size: 10px; }
.speaking-session-progress .speaking-progress-track { grid-column: 1 / -1; height: 5px; margin-top: 2px; }
.speaking-dialogue { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: start; gap: 10px; }
.speaking-partner-avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #e5f0df, #f4f7ed); color: #507d54; font-size: 10px; font-weight: 850; }
.speaking-partner-card { width: fit-content; max-width: 100%; padding: 14px 16px; border: 1px solid #e5ebe1; border-radius: 3px 12px 12px 12px; background: #fff; box-shadow: 0 4px 13px rgba(37, 62, 42, .04); }
.speaking-partner-card > span { color: #8a968b; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.speaking-partner-card p { margin: 6px 0 10px; color: #34483a; font-size: 16px; line-height: 1.5; }
.speaking-listen-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid #e2e9df; border-radius: 6px; background: #f9fbf7; color: #5c765f; cursor: pointer; font: inherit; font-size: 10px; }
.speaking-listen-btn:disabled { cursor: not-allowed; opacity: .5; }
.speaking-response-panel { padding: clamp(15px, 3vw, 22px); border: 1px solid #e3eae1; border-radius: 11px; background: linear-gradient(155deg, #fff 40%, #fafcf8); box-shadow: 0 6px 20px rgba(37, 62, 42, .045); }
.speaking-cue { margin: 0 0 15px; padding: 11px 13px; border-left: 3px solid #96b27d; border-radius: 0 6px 6px 0; background: #f3f7ee; color: #627364; font-size: 12px; line-height: 1.55; }
.speaking-response-panel > label { display: block; margin-bottom: 7px; color: #536457; font-size: 11px; font-weight: 750; }
.speaking-answer-row { display: flex; align-items: flex-end; gap: 8px; }
.speaking-answer-row textarea { min-height: 82px; flex: 1; resize: vertical; border: 1px solid #dfe7dc; border-radius: 7px; background: #fff; font-size: 13px; line-height: 1.5; }
.speaking-answer-row textarea:focus { border-color: #81a77c; outline: 3px solid rgba(105, 148, 119, .12); }
.speaking-mic-btn { width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid #dce6da; border-radius: 8px; background: #f8faf6; color: #527858; cursor: pointer; font-size: 17px; }
.speaking-mic-btn:disabled { cursor: not-allowed; opacity: .45; }
.speaking-mic-btn.recording { border-color: #c56a59; background: #fff0ed; color: #a83c31; }
.speaking-feedback { margin-top: 12px; padding: 12px; border: 1px solid #e8e9d8; border-radius: 7px; background: #faf9ef; }
.speaking-feedback.is-good { border-color: #d8e8d7; background: #f2f8ef; }
.speaking-feedback strong { color: #536b4f; font-size: 12px; }
.speaking-feedback p { margin: 7px 0 4px; color: #59675c; font-size: 12px; line-height: 1.5; }
.speaking-feedback small { color: #879187; font-size: 10px; }
.speaking-session-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.speaking-session-actions .btn { width: auto; min-height: 40px; margin: 0; }
.speaking-result { min-height: 410px; }
.speaking-result .speaking-kicker { margin-top: 16px; }
.speaking-result h1 { margin: 0; color: #294432; font-size: clamp(24px, 4vw, 32px); }
.speaking-result-score { margin: 16px 0 4px; color: #4d8052; font-size: 44px; font-variant-numeric: tabular-nums; }
.speaking-result .btn { width: auto; margin-top: 10px; }

@media (max-width: 700px) {
  :root { --header-height: 62px; --nav-height: 66px; }
  .app-header {
    inset: 0 0 auto;
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 16px;
  }
  .brand { position: static; margin-right: auto; color: var(--purple); font-size: 21px; }
  .bottom-nav {
    inset: auto 0 0;
    width: 100%;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 2px;
    border-top: 1px solid var(--border);
    background: rgba(255, 254, 250, 0.97);
    backdrop-filter: blur(14px);
  }
  .nav-item {
    flex: 1 1 0;
    min-height: 50px;
    padding: 4px 2px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border-color: transparent;
    border-radius: 4px;
    color: #6a796f;
  }
  .nav-item:hover { color: var(--purple); background: #f0f3ea; }
  .nav-item.active { color: var(--purple-dark); background: #e8efe4; }
  .nav-item.active::before { inset: -6px 25% auto; width: 50%; height: 3px; }
  .nav-icon { flex-basis: 26px; font-size: 18px; }
  .nav-label { display: block; max-width: 100%; font-size: 9px; text-align: center; }
  .main-view {
    min-height: calc(100dvh - var(--header-height));
    margin: var(--header-height) 0 0;
    padding: 23px 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 22px);
  }
  #app:has(.auth-screen) .main-view { min-height: calc(100dvh - var(--header-height)); padding: 16px; }
  .main-view h1 { font-size: 29px; }
  .view-header-row { margin-bottom: 16px; }
  .card { padding: 18px; }
  .auth-screen { width: min(100%, 430px); padding: 20px 0; }
  .auth-logo { width: 60px; height: 60px; margin-bottom: 10px; font-size: 32px; }
  .auth-title { font-size: 26px; }
  .auth-tagline { margin-bottom: 18px; }
  .auth-form { padding: 18px; }
  .onboarding-screen { padding: 22px 18px; }
  .chip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .curriculum-unit-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .curriculum-unit { min-height: 70px; padding: 6px; }
  .level-exam-row { align-items: stretch; flex-direction: column; }
  .level-exam-row .btn { width: 100%; }
  .wa-chat-screen {
    inset: 0;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
    width: 100%;
    height: auto;
    max-width: none;
    transform: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  /* Keep the app's bottom navigation (z-30) visible above .main-view's
     opaque background while a chat is open; the chat ends above the nav. */
  .main-view:has(.wa-chat-screen) { z-index: 26; }
  .wa-input-row { padding-bottom: 10px; }
  .communication-subtitle { margin-bottom: 15px; }
  .communication-search { margin-bottom: 19px; }
  .communication-sections { gap: 18px; }
  .communication-section .wa-list-item { min-height: 72px; gap: 11px; padding: 11px 12px; }
  .ai-practice-tools { align-items: flex-start; flex-direction: column; gap: 6px; }
  .ai-practice-select { width: 100%; }
  .wa-list-arrow { font-size: 21px; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-content { border-radius: 8px 8px 0 0; }
  .settings-modal-content { max-height: 94dvh; padding: 18px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-course-row { grid-template-columns: minmax(0, 1fr); }
  .settings-course-row label, .settings-course-row .btn { grid-column: 1; grid-row: auto; }
  .toast { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px); }
  .back-to-top { right: 16px; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px); width: 46px; height: 46px; font-size: 21px; }
  .games-heading { align-items: flex-start; gap: 10px; }
  .games-heading h1 { font-size: 26px; }
  .translate-btn { min-height: 40px; padding: 8px 10px; font-size: 11px; }
  .translator-panel-heading { gap: 8px; }
  .translator-panel-heading h2 { font-size: 20px; }
  .translator-provider { max-width: 115px; white-space: normal; text-align: center; }
  .translator-form-footer .btn { min-width: 118px; }
  .translator-language-selects { grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr); gap: 7px; }
  .translator-language-selects select { padding-right: 22px; font-size: 12px; }
  .activity-overlay { padding: 0; }
  .activity-window { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .activity-window-header { min-height: 62px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .activity-window-header h2 { font-size: 20px; }
  .activity-window-body { padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }
  .game-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .game-grid .game-card { min-height: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 13px; align-items: center; }
  .game-grid .game-emoji { grid-row: 1 / span 2; width: 46px; height: 46px; margin: 0; font-size: 27px; }
  .game-grid .game-card h3 { min-height: 0; margin: 0; font-size: 17px; }
  .game-grid .game-card .play-btn { grid-column: 2; width: auto; justify-self: start; margin-top: 8px; }
  .topic-result { grid-template-columns: minmax(0, 1fr) 18px; gap: 5px 8px; }
  .topic-result-meta { grid-column: 1; grid-row: 2; }
  .topic-result-arrow { grid-column: 2; grid-row: 1 / span 2; }
  .topic-detail-heading h3 { font-size: 23px; }
  .dialogue-line { max-width: 94%; }
}

@media (max-width: 380px) {
  .nav-label { font-size: 8px; }
  .main-view { padding-right: 12px; padding-left: 12px; }
  .auth-screen { padding: 20px 16px; }
  .auth-screen > form { padding: 17px; }
  .match-grid { gap: 7px; }
  .match-cell { padding: 10px 5px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.admin-dashboard { display: grid; gap: 22px; max-width: 1440px; margin: 0 auto; }
.admin-heading { align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 0; }
.admin-heading-copy { min-width: 0; }
.admin-eyebrow { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; color: var(--green-dark); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.admin-eyebrow-mark { color: #d28a56; font-size: 15px; }
.admin-heading h1 { margin: 0; }
.admin-intro { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.admin-refresh { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: auto; min-height: 40px; flex: 0 0 auto; margin: 0; padding: 0 14px; border-radius: 7px; background: #fff; }
.admin-refresh > span:first-child { font-size: 19px; line-height: 1; }
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.admin-stat { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); grid-template-rows: auto auto auto; align-items: center; gap: 4px 10px; min-width: 0; min-height: 116px; padding: 16px; border: 1px solid #e5eae4; border-radius: 10px; background: linear-gradient(145deg, #fff 0%, #fbfcf9 100%); box-shadow: 0 4px 14px rgba(30, 57, 39, .035); }
.admin-stat-icon { grid-column: 1; grid-row: 1 / 4; display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: #edf4eb; color: #47754d; font-size: 16px; }
.admin-stat > span:not(.admin-stat-icon) { overflow: hidden; color: #69766d; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.admin-stat strong { color: #233b2c; font-size: 25px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.admin-stat small { overflow: hidden; color: #879188; font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.admin-stat-primary { border-color: #dce9dc; background: linear-gradient(145deg, #f5faf2, #fff); }
.admin-stat-primary .admin-stat-icon { background: #dfeede; }
.admin-users-section { min-width: 0; padding: 20px; border: 1px solid #e5eae4; border-radius: 10px; background: #fff; box-shadow: 0 5px 18px rgba(30, 57, 39, .04); }
.admin-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.admin-section-heading h2 { margin: 1px 0 0; color: #26382d; font-size: 20px; }
.admin-section-kicker { margin: 0; color: #879188; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.admin-result-count { flex: 0 0 auto; padding: 6px 10px; border: 1px solid #e6ece5; border-radius: 20px; background: #f8faf6; color: #617066; font-size: 11px; font-weight: 650; }
.admin-search { display: flex; gap: 8px; margin-bottom: 12px; }
.admin-search-field { display: flex; align-items: center; gap: 9px; min-width: 0; min-height: 42px; flex: 1; padding: 0 12px; border: 1px solid #dfe6df; border-radius: 7px; background: #fcfdfb; color: #77867a; }
.admin-search-field:focus-within { border-color: #78a17c; box-shadow: 0 0 0 3px rgba(105, 148, 119, .12); }
.admin-search-field > span { font-size: 21px; line-height: 1; }
.admin-search-field input { width: 100%; min-width: 0; min-height: 38px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; }
.admin-search .btn { width: auto; min-height: 42px; margin: 0; padding: 0 16px; border-radius: 7px; }
.admin-clear-search { flex: 0 0 auto; }
.admin-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.admin-filters label, .admin-rewards-form label { display: grid; gap: 5px; color: #707d73; font-size: 11px; font-weight: 650; }
.admin-filters select { min-width: 0; min-height: 38px; border-color: #e1e7e0; border-radius: 6px; background: #fff; font-size: 12px; }
.admin-table-wrap { overflow-x: auto; border: 1px solid #e5eae4; border-radius: 8px; }
.admin-users-table { width: 100%; min-width: 820px; border-collapse: separate; border-spacing: 0; text-align: left; }
.admin-users-table th, .admin-users-table td { padding: 12px 13px; border-bottom: 1px solid #edf0ec; font-size: 12px; vertical-align: middle; }
.admin-users-table th { position: sticky; top: 0; background: #f7f9f5; color: #6f7c71; font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.admin-users-table tbody tr { transition: background .15s ease; }
.admin-users-table tbody tr:hover { background: #fafcf9; }
.admin-users-table tr:last-child td { border-bottom: 0; }
.admin-user-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.admin-user-cell > span:last-child { min-width: 0; }
.admin-user-cell strong { display: block; max-width: 260px; overflow: hidden; color: #33443a; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.admin-user-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid #e3ebe0; border-radius: 50%; background: #f0f5eb; color: #46734b; font-size: 11px; font-weight: 800; }
.admin-user-email { display: block; max-width: 260px; margin-top: 3px; overflow: hidden; color: #879188; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.admin-number-cell { color: #425348; font-variant-numeric: tabular-nums; font-weight: 650; }
.admin-status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 20px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.admin-status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.admin-status.is-active { background: #eaf5ec; color: #267141; }
.admin-status.is-inactive { background: #fbefed; color: #a64d42; }
.admin-user-actions { display: flex; flex-wrap: nowrap; gap: 5px; }
.admin-user-actions .btn { min-height: 30px; padding: 0 8px; border-radius: 5px; font-size: 10px; white-space: nowrap; }
.admin-user-actions .btn:disabled { cursor: not-allowed; opacity: .48; }
.admin-empty-row { height: 150px; color: var(--text-muted); text-align: center !important; }
.admin-empty-row > * { display: block; }
.admin-empty-row strong { margin: 6px 0 3px; color: #526257; font-size: 13px; }
.admin-empty-row span:last-child { color: #879188; font-size: 11px; }
.admin-empty-icon { color: #93a393; font-size: 24px; }
.admin-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.admin-pagination span { color: #738076; font-size: 12px; font-variant-numeric: tabular-nums; }
.admin-pagination .icon-btn { width: 36px; height: 36px; border: 1px solid #e2e8e1; border-radius: 7px; background: #fff; }
.admin-loading { display: flex; min-height: 220px; align-items: center; justify-content: center; gap: 12px; color: #768278; font-size: 13px; }
.admin-error-state { display: grid; min-height: 300px; align-content: center; justify-items: center; padding: 28px; border: 1px solid #ece5e0; border-radius: 10px; background: #fff; text-align: center; }
.admin-error-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: #fbefed; color: #a64d42; font-size: 21px; font-weight: 800; }
.admin-error-state h2 { margin: 14px 0 4px; font-size: 18px; }
.admin-error-state p { max-width: 520px; margin: 0 0 16px; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.admin-user-modal-content { max-height: min(720px, calc(100dvh - 40px)); overflow-y: auto; }
.admin-user-modal-content h3 { margin: 18px 0 9px; font-size: 15px; }
.admin-user-detail-email { margin: -7px 0 14px; color: var(--text-muted); overflow-wrap: anywhere; }
.admin-user-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.admin-user-details div { padding: 9px; border: 1px solid var(--border); border-radius: 5px; }
.admin-user-details dt { color: var(--text-muted); font-size: 11px; }
.admin-user-details dd { margin: 4px 0 0; font-weight: 700; }
.admin-language-pairs { margin: 0; padding-left: 18px; }
.admin-rewards-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-rewards-form h3, .admin-rewards-form .btn { grid-column: 1 / -1; }
.admin-rewards-form .btn { width: auto; justify-self: start; margin: 2px 0 0; }
.admin-protected-note { margin: 18px 0 0; padding: 10px 12px; border-radius: 6px; background: #f7f8f4; color: #788278; font-size: 11px; }
.admin-user-modal-content { max-height: min(720px, calc(100dvh - 40px)); overflow-y: auto; }
.admin-user-modal-content h3 { margin: 18px 0 9px; font-size: 15px; }
.admin-user-detail-email { margin: -7px 0 14px; color: var(--text-muted); overflow-wrap: anywhere; }
.admin-user-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.admin-user-details div { padding: 9px; border: 1px solid var(--border); border-radius: 5px; }
.admin-user-details dt { color: var(--text-muted); font-size: 11px; }
.admin-user-details dd { margin: 4px 0 0; font-weight: 700; }
.admin-language-pairs { margin: 0; padding-left: 18px; }
.admin-rewards-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-rewards-form h3, .admin-rewards-form .btn { grid-column: 1 / -1; }
.admin-rewards-form .btn { width: auto; justify-self: start; margin: 2px 0 0; }

@media (max-width: 700px) {
  .profile-hero { padding: 17px; }
  .profile-scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-identity h1 { font-size: 22px; }
  .daily-lesson-hero { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .daily-lesson-copy h1 { font-size: 25px; }
  .daily-lesson-progress { grid-column: 1; grid-template-columns: auto auto 1fr; }
  .daily-lesson-cta { width: 100%; }
  .daily-course-header h1 { font-size: 21px; }
  .admin-dashboard { gap: 16px; }
  .admin-heading { align-items: flex-start; }
  .admin-heading h1 { font-size: 25px; }
  .admin-intro { max-width: 440px; font-size: 12px; }
  .admin-refresh { min-height: 36px; padding: 0 10px; font-size: 11px; }
  .admin-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-stat { min-height: 104px; gap: 4px 8px; padding: 11px; }
  .admin-stat-icon { width: 28px; height: 28px; }
  .admin-stat strong { font-size: 22px; }
  .admin-search { align-items: stretch; }
  .admin-search .btn { min-width: 70px; padding: 0 10px; font-size: 11px; }
  .admin-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-users-section { padding: 14px 12px; }
  .admin-section-heading h2 { font-size: 18px; }
  .admin-user-modal-content { padding: 16px; }
  .speaking-studio { gap: 15px; }
  .speaking-hero { min-height: 190px; gap: 5px; padding: 20px; border-radius: 11px; }
  .speaking-hero-art { width: 110px; height: 110px; margin-right: -15px; }
  .speaking-hero-mic { width: 61px; height: 61px; font-size: 27px; }
  .orbit-one { width: 96px; height: 96px; }
  .orbit-two { width: 122px; height: 122px; }
  .bubble-one { right: -2px; }
  .speaking-lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .speaking-lesson-card { min-height: 94px; }
  .speaking-progress-panel { padding: 14px; }
  .speaking-level-section { padding: 12px; }
  .speaking-session { gap: 15px; }
}

@media (max-width: 420px) {
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-refresh { align-self: flex-end; }
  .admin-search { flex-wrap: wrap; }
  .admin-search-field { flex-basis: 100%; }
  .admin-clear-search { flex: 1; }
  .admin-search > button[type="submit"] { flex: 1; }
  .admin-filters { gap: 8px; }
  .admin-user-details { grid-template-columns: 1fr 1fr; }
  .speaking-hero { align-items: flex-start; }
  .speaking-hero-art { position: absolute; right: 6px; bottom: 8px; width: 78px; height: 78px; opacity: .72; }
  .speaking-hero-art .orbit-one { width: 66px; height: 66px; }
  .speaking-hero-art .orbit-two { width: 86px; height: 86px; }
  .speaking-hero-mic { width: 45px; height: 45px; font-size: 20px; }
  .speaking-hero-description { max-width: calc(100% - 20px); }
  .speaking-pair-picker { position: relative; z-index: 3; }
  .speaking-session-actions .btn { flex: 1; }
}
