html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
  touch-action: pan-y;
}

.app-container, .main-wrapper, .content-body, .path-section, .unit-section-block, .unit-banner {
  max-width: 100%;
  box-sizing: border-box;
}

/* ==========================================================================
   QAZAQ LINGO - DUOLINGO DESIGN SYSTEM (6-сынып)
   Таза, жеңіл, заманауи және ыңғайлы Duolingo интерфейсі
   ========================================================================== */

:root {
  --duo-green: #58cc02;
  --duo-green-dark: #58a700;
  --duo-green-light: #d7ffb8;
  --duo-blue: #1cb0f6;
  --duo-blue-dark: #1899d6;
  --duo-blue-light: #ddf4ff;
  --duo-orange: #ff9600;
  --duo-orange-dark: #e68600;
  --duo-orange-light: #ffe8cc;
  --duo-red: #ff4b4b;
  --duo-red-dark: #ea2b2b;
  --duo-red-light: #ffdfe0;
  --duo-gold: #ffc800;
  --duo-gold-dark: #e6a800;
  --duo-purple: #a55eea;
  --duo-purple-dark: #8854d0;
  
  --duo-gray-bg: #ffffff;
  --duo-gray-panel: #f7f7f7;
  --duo-gray-border: #e5e5e5;
  --duo-gray-border-dark: #d5d5d5;
  --duo-gray-text: #777777;
  --duo-gray-dark: #4b4b4b;
  --duo-text-dark: #3c3c3c;
  
  --kazakh-cyan: #00afca;
  --kazakh-gold: #fec50c;
  
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-family: 'Nunito', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: #ffffff;
  color: var(--duo-text-dark);
  font-weight: 700;
  line-height: 1.45;
  overflow-x: hidden;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

input, button, select, textarea {
  font-family: var(--font-family);
  font-weight: 700;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  user-select: none;
}

/* ==========================================================================
   BUTTONS (Duolingo 3D Chunky Style)
   ========================================================================== */
.duo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.duo-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 transparent !important;
}

.duo-btn-green {
  background-color: var(--duo-green);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--duo-green-dark);
}
.duo-btn-green:hover:not(:disabled) {
  filter: brightness(1.05);
}

.duo-btn-blue {
  background-color: var(--duo-blue);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--duo-blue-dark);
}
.duo-btn-blue:hover:not(:disabled) {
  filter: brightness(1.05);
}

.duo-btn-orange {
  background-color: var(--duo-orange);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--duo-orange-dark);
}

.duo-btn-purple {
  background-color: var(--duo-purple);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--duo-purple-dark);
}

.duo-btn-red {
  background-color: var(--duo-red);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--duo-red-dark);
}

.duo-btn-white {
  background-color: #ffffff;
  color: var(--duo-blue);
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 4px 0 var(--duo-gray-border);
}
.duo-btn-white:hover {
  background-color: #f7f7f7;
}

.duo-btn-disabled, .duo-btn:disabled {
  background-color: #e5e5e5 !important;
  color: #afafaf !important;
  box-shadow: 0 4px 0 #d5d5d5 !important;
  cursor: not-allowed;
  transform: none !important;
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Left Sidebar */
.left-sidebar {
  width: 256px;
  border-right: 2px solid var(--duo-gray-border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  background: #ffffff;
  z-index: 50;
  overflow-y: auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px;
  text-decoration: none;
  cursor: pointer;
}

.logo-mascot-mini {
  width: 40px;
  height: 40px;
}

.brand-text {
  font-size: 24px;
  font-weight: 900;
  color: var(--duo-green);
  letter-spacing: -0.5px;
}
.brand-text span {
  color: var(--duo-orange);
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 800;
  color: var(--duo-gray-dark);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 2px solid transparent;
}

.nav-item:hover {
  background-color: #f7f7f7;
}

.nav-item.active {
  background-color: #ddf4ff;
  color: var(--duo-blue);
  border-color: #84d8ff;
}

.nav-item.highlight {
  color: var(--duo-purple-dark);
}
.nav-item.highlight.active {
  background-color: #f3e8ff;
  border-color: #d8b4fe;
  color: var(--duo-purple-dark);
}

.nav-icon {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 2px solid var(--duo-gray-border);
}

.textbook-badge {
  background: #fff4e6;
  border: 2px solid #ffd8a8;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 12px;
  color: #d9480f;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.textbook-badge strong {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main Content Area */
.main-wrapper {
  margin-left: 256px;
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 256px);
  display: flex;
  flex-direction: column;
}

/* Top Sticky Header */
.top-header {
  height: 70px;
  border-bottom: 2px solid var(--duo-gray-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.course-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--duo-gray-border);
  background: #ffffff;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.course-selector:hover {
  background: #f7f7f7;
}

.kz-flag {
  font-size: 20px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.stat-item:hover {
  background: #f7f7f7;
}

.stat-fire { color: var(--duo-orange); }
.stat-gem { color: var(--duo-blue); }
.stat-heart { color: var(--duo-red); }

.sound-toggle-btn {
  background: none;
  font-size: 20px;
  padding: 8px;
  border-radius: var(--radius-full);
  border: 2px solid var(--duo-gray-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.sound-toggle-btn:hover {
  background: #f7f7f7;
}

/* Content Body */
.content-body {
  display: flex;
  justify-content: center;
  padding: 32px 32px 80px;
  gap: 48px;
}

/* ==========================================================================
   THE CONTINUOUS DUOLINGO PATHWAY (Вниз красивой змейкой)
   ========================================================================== */
.path-section {
  width: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.unit-section-block {
  width: 100%;
  margin-bottom: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Duolingo Unit Header Card */
.unit-banner {
  width: 100%;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  color: #ffffff;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
}

.unit-banner::after {
  content: "⚡";
  position: absolute;
  right: -5px;
  bottom: -15px;
  font-size: 110px;
  opacity: 0.15;
  pointer-events: none;
}

.unit-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.unit-tag {
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
}

.unit-guide-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  font-weight: 800;
}
.unit-guide-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

.unit-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.unit-desc {
  font-size: 13px;
  opacity: 0.95;
  font-weight: 600;
  line-height: 1.45;
}

/* Snake Nodes Container */
.pathway-nodes-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  position: relative;
  width: 100%;
}

.path-node-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s;
  z-index: 5;
}

/* Fix: Активті плашка ашылғанда оның z-index мәні басқа түймелерден жоғары, бірақ сабақ экраны мен модальдерден төмен болуы тиіс */
.path-node-wrapper.popover-active {
  z-index: 30 !important;
}

/* Node Button */
.node-btn {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  position: relative;
  transition: all 0.15s;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  z-index: 6;
}

.node-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.node-btn.completed {
  background: var(--duo-gold) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 0 var(--duo-gold-dark) !important;
}

.node-btn.active-node {
  animation: pulse-ring 2s infinite;
  color: #ffffff;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 8px 0 var(--duo-green-dark), 0 0 0 0 rgba(88, 204, 2, 0.5); }
  70% { box-shadow: 0 8px 0 var(--duo-green-dark), 0 0 0 16px rgba(88, 204, 2, 0); }
  100% { box-shadow: 0 8px 0 var(--duo-green-dark), 0 0 0 0 rgba(88, 204, 2, 0); }
}

.node-btn.locked {
  background: #e5e5e5 !important;
  color: #afafaf !important;
  box-shadow: 0 8px 0 #d5d5d5 !important;
  cursor: not-allowed;
}

.node-btn.boss-node {
  width: 84px;
  height: 84px;
  font-size: 34px;
  background: #ffc800 !important;
  box-shadow: 0 8px 0 #e6a800 !important;
}

.node-label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--duo-text-dark);
  background: #ffffff;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 2px 0 var(--duo-gray-border);
  white-space: nowrap;
}

/* Companion Mascot beside the active node */
.path-mascot-companion {
  position: absolute;
  left: -130px;
  top: -10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  animation: float-anim 3s ease-in-out infinite;
  z-index: 20;
}

@keyframes float-anim {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.mascot-speech-bubble {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 800;
  color: var(--duo-text-dark);
  box-shadow: 0 4px 0 var(--duo-gray-border);
  white-space: nowrap;
  margin-bottom: 6px;
  position: relative;
}

.mascot-speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-right: 2px solid var(--duo-gray-border);
  border-bottom: 2px solid var(--duo-gray-border);
  transform: rotate(45deg);
}

/* Duolingo Node Popover Card (Интерактивная плашка запуска - баг перекрытия исправлен) */
.node-popover-card {
  position: absolute;
  top: 104px;
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 35 !important;
  animation: popover-bounce 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.node-popover-card::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-left: 2px solid var(--duo-gray-border);
  border-top: 2px solid var(--duo-gray-border);
}

@keyframes popover-bounce {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.popover-title {
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 4px;
}
.popover-desc {
  font-size: 12px;
  color: var(--duo-gray-dark);
  font-weight: 600;
  margin-bottom: 12px;
}
.popover-reward {
  font-size: 12px;
  font-weight: 800;
  color: var(--duo-gold-dark);
  margin-bottom: 14px;
}

/* ==========================================================================
   RIGHT SIDEBAR (Легкий и чистый дизайн)
   ========================================================================== */
.right-sidebar {
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-card {
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: #ffffff;
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-action {
  font-size: 13px;
  color: var(--duo-blue);
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 800;
}
.card-action:hover {
  text-decoration: underline;
}

.textbook-card {
  background: linear-gradient(145deg, #fff9f0 0%, #fff 100%);
  border-color: #ffd8a8;
}

.textbook-preview {
  display: flex;
  gap: 16px;
  align-items: center;
}

.orange-book-cover {
  width: 68px;
  height: 92px;
  background: linear-gradient(135deg, #ff8c00 0%, #e65100 100%);
  border-radius: 8px 12px 12px 8px;
  box-shadow: 4px 4px 12px rgba(230, 81, 0, 0.25), inset 4px 0 0 rgba(255, 255, 255, 0.3);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  color: #fff;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s;
}
.orange-book-cover:hover {
  transform: rotate(-3deg) scale(1.05);
}

.book-title-mini {
  font-size: 8px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}
.book-grade-badge {
  background: #ffffff;
  color: #e65100;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 4px;
  border-radius: 4px;
  align-self: flex-start;
}
.book-ornament {
  font-size: 16px;
  text-align: center;
}

.textbook-info h4 {
  font-size: 15px;
  margin-bottom: 4px;
  color: #d9480f;
}
.textbook-info p {
  font-size: 12px;
  color: var(--duo-gray-dark);
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

.quest-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--duo-gray-border);
}
.quest-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.quest-icon {
  font-size: 22px;
  width: 36px;
  height: 36px;
  background: #f7f7f7;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.quest-details {
  flex: 1;
}
.quest-desc {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.quest-progress-bar {
  height: 10px;
  background: #e5e5e5;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.quest-progress-fill {
  height: 100%;
  background: var(--duo-gold);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* ==========================================================================
   СЕПТЕГІШ & СӨЗГЕ ТОЛЫҚ ТАЛДАУ (Код из сайта пользователя)
   ========================================================================== */
.declension-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.declension-search-box {
  display: flex;
  gap: 12px;
  align-items: center;
}

.declension-input {
  flex: 1;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 4px 0 var(--duo-gray-border);
  font-size: 16px;
  font-weight: 700;
  color: var(--duo-text-dark);
  outline: none;
  transition: border-color 0.2s;
}
.declension-input:focus {
  border-color: var(--duo-blue);
  box-shadow: 0 4px 0 var(--duo-blue);
}

.mode-toggle-group {
  display: flex;
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 4px;
  background: #f7f7f7;
  gap: 4px;
}
.mode-toggle-btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  background: none;
  color: var(--duo-gray-dark);
}
.mode-toggle-btn.active {
  background: #ffffff;
  color: var(--duo-blue);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.preset-chips-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.preset-chip {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 2px 0 var(--duo-gray-border);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--duo-text-dark);
  cursor: pointer;
  transition: all 0.1s;
}
.preset-chip:hover {
  background: #f7f7f7;
  border-color: var(--duo-blue);
}
.preset-chip.active {
  background: #ddf4ff;
  border-color: #84d8ff;
  color: var(--duo-blue-dark);
}

.word-analysis-output {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.word-card-full {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  background: #ffffff;
}

.info {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 4px 0 var(--duo-gray-border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
}
.info h3 {
  font-size: 16px;
  font-weight: 900;
  color: var(--duo-text-dark);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.info p {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--duo-gray-dark);
  line-height: 1.5;
}
.info p b {
  color: var(--duo-text-dark);
}
.info p:last-child {
  margin-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 800;
  margin-right: 6px;
  margin-bottom: 6px;
}
.badge-plural { background: #e7f5ff; color: #1971c2; border: 1px solid #a5d8ff; }
.badge-poss { background: #f3f0ff; color: #7950f2; border: 1px solid #d0bfff; }
.badge-case { background: #fff4e6; color: #d9480f; border: 1px solid #ffd8a8; }
.badge-default { background: #ebfbee; color: #2b8a3e; border: 1px solid #b2f2bb; }

.word-build {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.morph-part {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}
.morph-root { background: #e6fcf5; border: 2px solid #63e6be; color: #0ca678; }
.morph-plur { background: #e7f5ff; border: 2px solid #74c0fc; color: #1c7ed6; }
.morph-poss { background: #f3f0ff; border: 2px solid #b197fc; color: #7048e8; }
.morph-case { background: #fff4e6; border: 2px solid #ffa94d; color: #f76707; }
.morph-plus { font-size: 18px; font-weight: 900; color: var(--duo-gray-text); }

.sound-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.sound-box {
  background: #f8f9fa;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 3px 0 var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--duo-blue-dark);
}
.sound-box b {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--duo-gray-text);
  letter-spacing: 0.5px;
}

.letters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.letter-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 3px 0 var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.letter-char {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
}
.letter-type {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.letter-desc {
  font-size: 11px;
  color: var(--duo-gray-dark);
  font-weight: 700;
  line-height: 1.3;
}

.cases-card-table {
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 6px 0 var(--duo-gray-border);
}
.cases-header-row {
  display: grid;
  grid-template-columns: 2.2fr 1.6fr 1.8fr 2.4fr 48px;
  padding: 12px 20px;
  background: #f7f7f7;
  border-bottom: 2px solid var(--duo-gray-border);
  font-size: 12px;
  font-weight: 800;
  color: var(--duo-gray-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.case-row-item {
  display: grid;
  grid-template-columns: 2.2fr 1.6fr 1.8fr 2.4fr 48px;
  padding: 12px 20px;
  align-items: center;
  border-bottom: 1px solid var(--duo-gray-border);
  font-size: 14px;
  transition: background 0.15s;
}
.case-row-item:last-child {
  border-bottom: none;
}
.case-row-item:hover {
  background: #fafafa;
}
.case-name-cell h4 {
  font-size: 15px;
  font-weight: 800;
  color: var(--duo-text-dark);
}
.case-name-cell span {
  font-size: 12px;
  color: var(--duo-gray-text);
}
.case-quest-cell {
  font-size: 13px;
  font-weight: 700;
  color: var(--duo-blue-dark);
}
.case-result-cell {
  font-size: 15px;
  font-weight: 900;
  color: var(--duo-green-dark);
}
.case-example-cell {
  font-size: 13px;
  color: var(--duo-gray-dark);
}

.trainer-box {
  background: linear-gradient(145deg, #f3f0ff 0%, #ffffff 100%);
  border: 2px solid #d8b4fe;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 6px 0 #c084fc;
  margin-top: 16px;
}
.trainer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 900;
  color: var(--duo-purple-dark);
  margin-bottom: 12px;
}

/* ==========================================================================
   INTERACTIVE LESSON VIEW
   ========================================================================== */
.lesson-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 100;
  display: flex;
  flex-direction: column;
  display: none;
}
.lesson-screen.active {
  display: flex;
}
.lesson-header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  gap: 32px;
}
.lesson-close-btn {
  background: none;
  border: none;
  font-size: 26px;
  color: #afafaf;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
}
.lesson-close-btn:hover {
  color: var(--duo-gray-dark);
}
.lesson-progress-container {
  flex: 1;
  height: 16px;
  background: #e5e5e5;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.lesson-progress-fill {
  height: 100%;
  background: var(--duo-green);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
.lesson-progress-fill::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  height: 4px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-full);
}
.lesson-hearts {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
  color: var(--duo-red);
}

.lesson-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 24px 120px;
  overflow-y: auto;
}
.lesson-question-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--duo-text-dark);
  align-self: flex-start;
  margin-bottom: 24px;
}

.dialogue-prompt-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 32px;
  width: 100%;
}
.dialogue-mascot {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}
.prompt-speech-bubble {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 19px;
  color: var(--duo-text-dark);
  position: relative;
  box-shadow: 0 4px 0 var(--duo-gray-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.prompt-speech-bubble::before {
  content: "";
  position: absolute;
  top: 24px;
  left: -8px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-left: 2px solid var(--duo-gray-border);
  border-bottom: 2px solid var(--duo-gray-border);
  transform: rotate(45deg);
}

.audio-btn {
  background: var(--duo-blue);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 3px 0 var(--duo-blue-dark);
  flex-shrink: 0;
  transition: transform 0.1s;
}
.audio-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.word-answer-slots {
  width: 100%;
  min-height: 64px;
  border-top: 2px solid var(--duo-gray-border);
  border-bottom: 2px solid var(--duo-gray-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  margin-bottom: 36px;
}
.word-bank-chips {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.word-chip {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 4px 0 var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  color: var(--duo-text-dark);
  cursor: pointer;
  transition: all 0.1s;
  user-select: none;
}
.word-chip:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--duo-gray-border);
}
.word-chip.used {
  background: #e5e5e5;
  color: transparent;
  border-color: #e5e5e5;
  box-shadow: 0 4px 0 #d5d5d5;
  cursor: default;
  pointer-events: none;
}

.choice-options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.choice-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 4px 0 var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--duo-text-dark);
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.1s;
}
.choice-card:hover {
  background: #f7f7f7;
}
.choice-card.selected {
  border-color: #84d8ff;
  background: #ddf4ff;
  color: var(--duo-blue-dark);
  box-shadow: 0 4px 0 #84d8ff;
}
.choice-index-key {
  width: 28px;
  height: 28px;
  border: 2px solid var(--duo-gray-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--duo-gray-text);
  font-weight: 800;
}
.choice-card.selected .choice-index-key {
  border-color: var(--duo-blue);
  color: var(--duo-blue);
}

.pair-grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.pair-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pair-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 4px 0 var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pair-card:hover {
  background: #f7f7f7;
}
.pair-card.selected {
  border-color: #84d8ff;
  background: #ddf4ff;
  color: var(--duo-blue);
  box-shadow: 0 4px 0 #84d8ff;
}
.pair-card.matched {
  background: #e5e5e5;
  color: #afafaf;
  border-color: #d5d5d5;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
  transform: scale(0.98);
}
.pair-card.error {
  border-color: var(--duo-red);
  background: var(--duo-red-light);
  color: var(--duo-red);
  animation: shake 0.3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.fill-blank-sentence {
  font-size: 21px;
  font-weight: 800;
  margin-bottom: 32px;
  text-align: center;
  line-height: 1.8;
}
.blank-slot {
  display: inline-block;
  min-width: 120px;
  border-bottom: 3px solid var(--duo-blue);
  color: var(--duo-blue);
  padding: 0 10px;
  text-align: center;
}

.lesson-footer-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 2px solid var(--duo-gray-border);
  background: #ffffff;
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 110;
  transition: background-color 0.25s, border-color 0.25s;
}
.feedback-left {
  display: flex;
  align-items: center;
  gap: 18px;
}
.feedback-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.feedback-message-box h3 {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 4px;
}
.feedback-message-box p {
  font-size: 14px;
  font-weight: 600;
}
.lesson-footer-drawer.correct {
  background-color: var(--duo-green-light);
  border-color: var(--duo-green-light);
}
.lesson-footer-drawer.correct .feedback-icon-circle { background: #ffffff; color: var(--duo-green); }
.lesson-footer-drawer.correct .feedback-message-box h3,
.lesson-footer-drawer.correct .feedback-message-box p { color: var(--duo-green-dark); }
.lesson-footer-drawer.wrong {
  background-color: var(--duo-red-light);
  border-color: var(--duo-red-light);
}
.lesson-footer-drawer.wrong .feedback-icon-circle { background: #ffffff; color: var(--duo-red); }
.lesson-footer-drawer.wrong .feedback-message-box h3,
.lesson-footer-drawer.wrong .feedback-message-box p { color: var(--duo-red-dark); }

.complete-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  display: none;
}
.complete-screen.active {
  display: flex;
}
.complete-mascot {
  width: 140px;
  height: 140px;
  margin-bottom: 24px;
  animation: bounce 0.6s infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-16px); }
}
.complete-title {
  font-size: 30px;
  font-weight: 900;
  color: var(--duo-gold-dark);
  margin-bottom: 8px;
}
.complete-subtitle {
  font-size: 16px;
  color: var(--duo-gray-dark);
  margin-bottom: 32px;
}
.complete-stats-row {
  display: flex;
  gap: 20px;
  margin-bottom: 40px;
  width: 100%;
  max-width: 500px;
}
.stat-card-box {
  flex: 1;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}
.stat-card-box.xp { background: #fff4e6; border: 2px solid #ffd8a8; color: var(--duo-orange-dark); }
.stat-card-box.accuracy { background: #e6fcf5; border: 2px solid #96f2d7; color: #0ca678; }
.stat-card-box.streak { background: #fff0f6; border: 2px solid #fcc2d7; color: #d6336c; }
.stat-card-val { font-size: 24px; font-weight: 900; }
.stat-card-lbl { font-size: 12px; text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 24px;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-window {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-window { transform: translateY(0); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 2px solid var(--duo-gray-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fdfdfd;
}
.modal-title { font-size: 20px; font-weight: 900; display: flex; align-items: center; gap: 10px; }
.modal-close-btn { background: none; font-size: 24px; color: #afafaf; }
.modal-close-btn:hover { color: var(--duo-gray-dark); }
.modal-content-scroll { padding: 24px; overflow-y: auto; flex: 1; }

.tb-nav-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--duo-gray-border);
  margin-bottom: 20px;
}
.tb-tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 800;
  color: var(--duo-gray-dark);
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tb-tab-btn.active { color: var(--duo-orange); border-bottom-color: var(--duo-orange); }

.tb-vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.tb-vocab-card {
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.tb-vocab-info h4 { font-size: 16px; font-weight: 800; color: var(--duo-text-dark); margin-bottom: 4px; }
.tb-vocab-info p { font-size: 13px; color: var(--duo-gray-dark); font-weight: 600; }
.tb-vocab-info .example { font-size: 12px; color: var(--duo-gray-text); font-style: italic; margin-top: 6px; }

.grammar-block {
  margin-bottom: 24px;
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 18px;
}
.grammar-block h4 { font-size: 17px; font-weight: 800; margin-bottom: 8px; color: var(--duo-blue); }
.grammar-rule { font-size: 14px; margin-bottom: 12px; line-height: 1.5; }
.grammar-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13px; }
.grammar-table th, .grammar-table td { border: 1px solid var(--duo-gray-border); padding: 8px 12px; text-align: left; }
.grammar-table th { background: #f7f7f7; font-weight: 800; }

.view-container {
  display: none;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px;
}
.view-container.active { display: block; }

/* ==========================================================================
   AUTHENTIC DUOLINGO LEADERBOARD / LEAGUE SYSTEM
   ========================================================================== */
.leaderboard-header-banner {
  background: linear-gradient(135deg, #1cb0f6 0%, #0092d6 100%);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  box-shadow: 0 6px 0 #0077b0;
  position: relative;
  overflow: hidden;
}
.leaderboard-header-banner::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 140px;
  height: 140px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  pointer-events: none;
}
.league-trophy-icon {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
  animation: bounceMini 2s infinite ease-in-out;
}
@keyframes bounceMini {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.league-info-text {
  flex: 1;
  text-align: left;
}
.league-badge-top {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  background: rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.league-title-main {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.league-subtitle {
  font-size: 13px;
  opacity: 0.95;
  font-weight: 600;
  line-height: 1.4;
}
.league-timer-box {
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.league-filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-md);
  background: #ffffff;
  gap: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.leaderboard-row:hover {
  transform: translateY(-2px);
  border-color: var(--duo-blue);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.leaderboard-row.user-row {
  border-color: #84d8ff;
  background: #eef9ff;
  box-shadow: 0 4px 0 #b3e7ff;
}
.leaderboard-row.user-row.active-user-glow {
  border-color: var(--duo-blue);
}
.leaderboard-row.registered-account-row {
  background: #fbfdff;
}

.rank-num {
  font-size: 18px;
  font-weight: 900;
  width: 34px;
  text-align: center;
  color: var(--duo-gray-dark);
}
.rank-num.rank-gold { font-size: 24px; }
.rank-num.rank-silver { font-size: 24px; }
.rank-num.rank-bronze { font-size: 24px; }

.user-avatar {
  font-size: 28px;
  line-height: 1;
}
.user-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}
.user-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.user-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--duo-text-dark);
}
.user-sub-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--duo-gray-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.league-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}
.league-pill-me {
  background: var(--duo-green);
  color: #ffffff;
}
.league-pill-registered {
  background: #e1f3fe;
  color: var(--duo-blue-dark);
  border: 1px solid #b8e2fb;
}
.league-pill-class {
  background: #f0f0f0;
  color: var(--duo-gray-dark);
}

.user-xp-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.user-xp-box .xp-val {
  font-size: 18px;
  font-weight: 900;
  color: var(--duo-text-dark);
}
.user-xp-box .xp-lbl {
  font-size: 12px;
  font-weight: 800;
  color: var(--duo-yellow);
}

.league-zone-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.6px;
  margin: 4px 0;
}
.league-zone-divider.promotion-zone {
  background: #f0fbf0;
  color: var(--duo-green-dark);
  border: 1px dashed var(--duo-green);
}
.league-zone-divider.demotion-zone {
  background: #fff0f0;
  color: var(--duo-red-dark);
  border: 1px dashed var(--duo-red);
}

.shop-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.shop-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 2px solid var(--duo-gray-border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.shop-card-left { display: flex; align-items: center; gap: 16px; }
.shop-card-icon { font-size: 36px; }
.shop-card-info h4 { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.shop-card-info p { font-size: 13px; color: var(--duo-gray-dark); font-weight: 600; }

/* ==========================================================================
   AUTHENTICATION & MULTI-USER SYSTEM (Duolingo Style)
   ========================================================================== */
.auth-container {
  padding: 4px 6px 16px;
}

.auth-title-box {
  text-align: center;
  margin-bottom: 20px;
}
.auth-title-box h3 {
  font-size: 22px;
  font-weight: 900;
  color: var(--duo-text-dark);
  margin-bottom: 6px;
}
.auth-title-box p {
  font-size: 14px;
  color: var(--duo-gray-dark);
  line-height: 1.45;
}

.auth-form-group {
  margin-bottom: 16px;
  text-align: left;
}
.auth-label {
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: var(--duo-gray-text);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-input-wrap .auth-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.7;
}
.auth-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 700;
  color: var(--duo-text-dark);
  background: #f7f7f7;
  border: 2px solid var(--duo-gray-border);
  border-radius: 14px;
  outline: none;
  transition: all 0.2s;
}
.auth-input:focus {
  background: #ffffff;
  border-color: var(--duo-blue);
  box-shadow: 0 0 0 3px rgba(28, 176, 246, 0.2);
}
.auth-toggle-pass {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  color: var(--duo-gray-dark);
  transition: transform 0.15s;
}
.auth-toggle-pass:hover {
  transform: scale(1.15);
}

/* Avatar Selector Grid */
.auth-avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 6px;
}
.auth-avatar-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}
.auth-avatar-chip span.emoji {
  font-size: 26px;
  margin-bottom: 2px;
}
.auth-avatar-chip span.name {
  font-size: 10px;
  font-weight: 800;
  color: var(--duo-gray-dark);
}
.auth-avatar-chip:hover {
  background: #f4faff;
  border-color: var(--duo-blue);
  transform: translateY(-2px);
}
.auth-avatar-chip.selected {
  background: #eef8ff;
  border-color: var(--duo-blue);
  box-shadow: 0 3px 0 var(--duo-blue-dark);
}

/* Bonus Box */
.auth-bonus-box {
  background: linear-gradient(135deg, #fff7d6 0%, #fff0b3 100%);
  border: 2px solid #fedb41;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #8f6500;
  box-shadow: 0 2px 0 #eed030;
}

/* Alerts */
.auth-alert {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.2s;
}
.auth-alert-error {
  background: #ffebeb;
  border: 2px solid var(--duo-red);
  color: var(--duo-red-dark);
}
.auth-alert-success {
  background: #ebfaeb;
  border: 2px solid var(--duo-green);
  color: var(--duo-green-dark);
}

/* Saved Accounts List */
.auth-saved-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 2px solid var(--duo-gray-border);
}
.auth-saved-title {
  font-size: 11px;
  font-weight: 900;
  color: var(--duo-gray-text);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 10px;
  text-align: left;
}
.auth-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f7f7f7;
  border: 2px solid var(--duo-gray-border);
  border-radius: 14px;
  margin-bottom: 8px;
  transition: all 0.15s;
}
.auth-account-card:hover {
  border-color: var(--duo-blue);
  background: #ffffff;
}
.auth-account-card.active-card {
  border-color: var(--duo-green);
  background: #f0fbf0;
}
.auth-acc-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  flex: 1;
}
.auth-acc-avatar {
  font-size: 28px;
}
.auth-acc-meta {
  text-align: left;
}
.auth-acc-name {
  font-size: 15px;
  font-weight: 900;
  color: var(--duo-text-dark);
}
.auth-acc-stats {
  font-size: 12px;
  font-weight: 700;
  color: var(--duo-gray-dark);
}
.auth-acc-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.auth-delete-btn {
  background: none;
  border: none;
  color: var(--duo-gray-text);
  font-size: 15px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.15s;
}
.auth-delete-btn:hover {
  color: var(--duo-red);
  background: #ffebee;
}

/* Profile Tab View */
.profile-hero {
  text-align: center;
  padding: 6px 0 16px;
}
.profile-avatar-large {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.08));
}
.profile-username {
  font-size: 24px;
  font-weight: 900;
  color: var(--duo-text-dark);
  margin-bottom: 2px;
}
.profile-sub {
  font-size: 13px;
  font-weight: 700;
  color: var(--duo-gray-dark);
  margin-bottom: 14px;
}
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.profile-stat-box {
  background: #f7f7f7;
  border: 2px solid var(--duo-gray-border);
  border-radius: 14px;
  padding: 12px;
  text-align: left;
}
.profile-stat-box .lbl {
  font-size: 11px;
  font-weight: 900;
  color: var(--duo-gray-text);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.profile-stat-box .val {
  font-size: 18px;
  font-weight: 900;
  color: var(--duo-text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

@media (max-width: 1024px) {
  .right-sidebar { display: none; }
  .top-header { padding: 0 16px; }
  .header-stats { gap: 10px; }
  .course-selector { padding: 6px 10px; font-size: 13px; }
  .cases-header-row, .case-row-item { grid-template-columns: 2fr 1.5fr 1.5fr 40px; }
  .case-example-cell { display: none; }
  .word-card-full { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Mobile Viewport & Full Width Optimization (При открытии на телефоне всё видно сразу) */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  .top-header {
    height: 54px !important;
    padding: 0 8px !important;
    gap: 6px !important;
    overflow: hidden !important;
  }
  .header-left {
    min-width: 0 !important;
    flex-shrink: 1 !important;
  }
  .course-selector {
    padding: 4px 6px !important;
    font-size: 12px !important;
    gap: 4px !important;
  }
  .course-selector span:nth-child(2) {
    max-width: 70px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 12px !important;
  }
  .header-stats {
    gap: 4px !important;
    flex-shrink: 0 !important;
  }
  .stat-item {
    padding: 3px 6px !important;
    font-size: 11px !important;
    gap: 3px !important;
    border-radius: 999px !important;
  }
  .stat-item span:first-child {
    font-size: 13px !important;
  }
  .sound-toggle-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 13px !important;
    padding: 0 !important;
  }
  #header-user-btn {
    padding: 3px 6px !important;
    gap: 4px !important;
    font-size: 11px !important;
  }
  #header-user-btn span:last-child {
    max-width: 50px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 11px !important;
  }
  .content-body {
    padding: 12px 12px 76px !important;
    gap: 0 !important;
  }
  .path-section {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  .node-popover-card {
    width: min(280px, calc(100vw - 32px)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
  .unit-banner {
    padding: 16px 16px !important;
    margin-bottom: 24px !important;
  }
  .unit-title {
    font-size: 17px !important;
    line-height: 1.3 !important;
  }
  .unit-desc {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }
  .modal-window {
    width: calc(100% - 24px) !important;
    max-width: 440px !important;
    margin: 10px auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  .left-sidebar {
    width: 100%;
    height: 64px;
    top: auto;
    bottom: 0;
    flex-direction: row;
    padding: 0;
    border-right: none !important;
    border-top: 2px solid var(--duo-gray-border) !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #ffffff;
    z-index: 90;
  }
  .left-sidebar::-webkit-scrollbar { display: none; }
  .brand-logo, .sidebar-footer { display: none; }
  .nav-links {
    flex-direction: row;
    width: auto;
    min-width: 100%;
    justify-content: flex-start;
    gap: 4px;
    padding: 0 8px;
    margin: 0;
  }
  .nav-item {
    flex-direction: column;
    flex-shrink: 0;
    min-width: 68px;
    padding: 6px 8px;
    font-size: 10px;
    gap: 3px;
    white-space: nowrap;
    text-align: center;
  }
  .nav-item span:not(.nav-icon) { font-size: 10px; }
  .main-wrapper { margin-left: 0; max-width: 100%; margin-bottom: 64px; }
  .top-header { padding: 0 16px; }
  .content-body { padding: 16px; }
  .path-section { width: 100%; }
  .path-mascot-companion { display: none; }
  .lesson-footer-drawer { flex-direction: column; gap: 16px; padding: 16px; text-align: center; }
  .feedback-left { flex-direction: column; }
  .duo-btn:not(.shop-card .duo-btn):not(.btn-group .duo-btn):not(.duo-btn-sm):not(.clan-card .duo-btn):not(.league-actions-wrap .duo-btn) { width: 100%; }
  .declension-search-box { flex-direction: column; }
  .sound-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-avatar-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .tb-nav-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tb-nav-tabs::-webkit-scrollbar { display: none; }
}

/* ==========================================================================
   GLOBAL DUOLINGO FLOATING TOAST NOTIFICATION
   ========================================================================== */
.qazaq-toast-banner {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--duo-green);
  color: white;
  padding: 12px 28px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  z-index: 999999;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid white;
}
.qazaq-toast-banner.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.qazaq-toast-banner.error {
  background: var(--duo-red);
}

.auth-account-card {
  cursor: pointer;
}
.auth-account-card:hover {
  background: #f0f7ff !important;
  border-color: var(--duo-blue) !important;
  transform: translateY(-1px);
}
.auth-account-card.active-card {
  background: #f2fbf0 !important;
  border-color: var(--duo-green) !important;
}

/* ==========================================================================
   LEAGUE HEADER & META ROW ENHANCEMENTS
   ========================================================================== */
.league-filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.league-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--duo-gray-dark);
  background: #f7f7f7;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--duo-gray-border);
}

.league-meta-dot {
  color: var(--duo-gray-border);
}

.league-actions-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 768px) {
  .leaderboard-header-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 16px;
  }
  .leaderboard-header-banner::after {
    display: none;
  }
  .league-trophy-icon {
    font-size: 40px;
  }
  .league-title-main {
    font-size: 20px;
  }
  .league-subtitle {
    font-size: 13px;
  }
  .league-timer-box {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 12px;
    box-sizing: border-box;
  }
  .league-filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .league-meta-pill {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }
  .league-actions-wrap {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .league-actions-wrap .duo-btn {
    flex: 1;
  }
  .leaderboard-row {
    padding: 10px 12px;
    gap: 10px;
  }
  .rank-num {
    font-size: 15px;
    width: 26px;
  }
  .user-avatar {
    font-size: 26px;
    width: 40px;
    height: 40px;
  }
  .user-name {
    font-size: 14px;
  }
  .user-sub-meta {
    font-size: 11px;
    gap: 4px;
  }
  .user-xp-box .xp-val {
    font-size: 16px;
  }
  .user-xp-box .xp-lbl {
    font-size: 10px;
  }
}

/* ====================================================================
   QAZAQSTAN NATIONAL AVATAR BADGE SYSTEM
   ==================================================================== */
.user-avatar {
  font-size: 24px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
  border: 2px solid #00bcd4;
  box-shadow: 0 3px 0 #0097a7;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.leaderboard-row:hover .user-avatar {
  transform: scale(1.1) rotate(4deg);
}

.auth-acc-avatar {
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
  border: 2px solid #00bcd4;
  box-shadow: 0 3px 0 #0097a7;
  flex-shrink: 0;
}

.profile-avatar-large {
  font-size: 58px;
  line-height: 1;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 50%, #80deea 100%);
  border: 4px solid #00bcd4;
  box-shadow: 0 5px 0 #0097a7, 0 8px 16px rgba(0, 188, 212, 0.25);
}

.profile-mini-avatar-chip {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #f0f7f9;
  border: 2px solid #b2ebf2;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 2px;
  box-sizing: border-box;
}
.profile-mini-avatar-chip:hover {
  transform: scale(1.18);
  border-color: #00bcd4;
}
.profile-mini-avatar-chip.selected {
  background: #e0f7fa;
  border-color: #00bcd4;
  box-shadow: 0 0 0 2px #ffc107;
  transform: scale(1.15);
}

.auth-avatar-chip {
  padding: 8px 4px;
  border: 2px solid #b2ebf2;
  background: #fbfdfe;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.auth-avatar-chip .avatar-icon-wrap {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.auth-avatar-chip .avatar-icon-wrap img {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.auth-avatar-chip span.name {
  font-size: 10px;
  font-weight: 800;
  color: var(--duo-gray-dark);
  text-align: center;
  line-height: 1.2;
}
.auth-avatar-chip.selected {
  background: #e0f7fa;
  border-color: #00bcd4;
  box-shadow: 0 3px 0 #0097a7;
}

.auth-acc-avatar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}
.kz-avatar-img {
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.auth-avatar-chip:hover .kz-avatar-img,
.profile-mini-avatar-chip:hover .kz-avatar-img {
  transform: scale(1.08);
}

/* ==========================================================================
   DUOLINGO FULLSCREEN WELCOME & ONBOARDING SCREEN
   ========================================================================== */
.auth-welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #ffffff;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-welcome-screen.active {
  display: flex;
}

.welcome-pane {
  display: none;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.welcome-pane.active {
  display: flex;
}

.welcome-content-card {
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
}

.welcome-mascot-wrap {
  width: 150px;
  height: 150px;
  margin-bottom: 12px;
  animation: duoFloat 3s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-mascot-mini-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes duoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.welcome-title {
  font-size: 38px;
  font-weight: 900;
  color: #235390;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

.welcome-title span {
  color: #58cc02;
}

.welcome-subtitle {
  font-size: 16px;
  font-weight: 700;
  color: #777777;
  line-height: 1.45;
  margin: 0 0 16px;
  max-width: 320px;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eef8ff;
  color: #1899d6;
  border: 2px solid #bce6ff;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 36px;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.welcome-main-btn {
  padding: 15px 24px;
  font-size: 15px;
  letter-spacing: 0.6px;
  width: 100%;
}

.welcome-header-bar {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 18px;
  border-bottom: 2px solid #e5e5e5;
  margin-bottom: 20px;
}

.welcome-back-btn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 900;
  color: #afafaf;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 10px;
  transition: all 0.15s;
}

.welcome-back-btn:hover {
  color: #4b4b4b;
  background: #f0f0f0;
}

.welcome-bar-title {
  font-size: 18px;
  font-weight: 900;
  color: #4b4b4b;
}

.welcome-form-card {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.welcome-saved-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 2px solid #e5e5e5;
  width: 100%;
}


/* ==========================================================================
   MISSING INTERACTIVE CLASSES & COMPONENT POLISH
   ========================================================================== */
.open-textbook-btn {
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.open-textbook-btn:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

.unit-switcher-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
  margin-bottom: 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.unit-switcher-nav::-webkit-scrollbar {
  display: none;
}

.unit-tab-pill {
  border: 2px solid var(--duo-gray-border);
  background: #ffffff;
  color: var(--duo-gray-dark);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--duo-gray-border);
  transition: all 0.15s ease;
  user-select: none;
}
.unit-tab-pill:hover {
  background: #f7f9fa;
  border-color: #d1d5db;
}
.unit-tab-pill.active {
  background: var(--duo-blue);
  color: #ffffff;
  border-color: var(--duo-blue-dark);
  box-shadow: 0 3px 0 var(--duo-blue-dark);
}

.declension-cat-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.timer-icon {
  font-size: 16px;
}
.timer-text {
  font-weight: 800;
  font-size: 13px;
  color: var(--duo-gray-dark);
}

.duo-btn-sm {
  padding: 6px 14px !important;
  font-size: 12px !important;
  border-radius: 12px !important;
  min-height: unset !important;
}

.auth-tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 14px;
  color: var(--duo-gray-dark);
  cursor: pointer;
  transition: all 0.15s ease;
}
.auth-tab-btn:hover {
  color: var(--duo-blue);
}
.auth-tab-btn.active {
  color: var(--duo-blue-dark);
  border-bottom-color: var(--duo-blue);
}

.auth-saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.trainer-choice-btn {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--duo-gray-border);
  transition: all 0.15s;
}
.trainer-choice-btn:hover {
  background: #f7f9fa;
  border-color: var(--duo-blue);
}

.kz-avatar-fallback {
  font-size: 26px;
  display: inline-block;
  line-height: 1;
}

.warning {
  color: var(--duo-red-dark);
  font-weight: 700;
}

.grammar-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border: 1px solid var(--duo-gray-border);
  border-radius: 12px;
  background: #ffffff;
}

/* ==========================================================================
   CLANS SYSTEM STYLES (QAZAQLINGO CLANS)
   ========================================================================== */
.clan-view-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

/* Hero Banner */
.clan-hero-banner {
  background: linear-gradient(135deg, #0288d1 0%, #005b9f 100%);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(2, 136, 209, 0.25);
}

.clan-hero-content {
  max-width: 580px;
  z-index: 2;
}

.clan-hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.clan-hero-title {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 10px;
  color: #ffffff;
}

.clan-hero-desc {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 20px;
}

.clan-hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.clan-hero-illustration {
  display: flex;
  gap: 12px;
  position: relative;
}

.clan-floating-emblem {
  font-size: 54px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
  animation: float-badge 3s ease-in-out infinite;
}
.clan-floating-emblem.delay-1 {
  animation-delay: 1s;
}
.clan-floating-emblem.delay-2 {
  animation-delay: 2s;
}

@keyframes float-badge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Clan Section Header */
.clan-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.clan-tabs-nav {
  display: flex;
  gap: 8px;
}

.clan-search-box input {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 12px;
}

/* Clan Cards Grid */
.clan-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.clan-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 0 var(--duo-gray-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.clan-card:hover {
  transform: translateY(-2px);
  border-color: var(--duo-blue);
  box-shadow: 0 6px 0 var(--duo-blue-dark);
}

.clan-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clan-card-badge-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #f0f7ff;
  border: 2px solid #cbe4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

.clan-card-title-box {
  overflow: hidden;
}

.clan-card-name {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clan-card-leader {
  font-size: 12px;
  color: var(--duo-gray-dark);
  font-weight: 600;
}

.clan-card-desc {
  font-size: 13px;
  color: var(--duo-gray-text);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.clan-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
}

.clan-card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
}

.clan-tag-badge {
  background: #eef8ff;
  color: var(--duo-blue-dark);
  border: 1px solid #bde0fe;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.clan-tag-mini {
  background: #fff4e5;
  color: #b25e00;
  border: 1px solid #ffd8a8;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}

/* Clan Dashboard (Affiliated User View) */
.clan-dashboard-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 0 var(--duo-gray-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.clan-dashboard-main {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex: 1;
  min-width: 280px;
}

.clan-large-emblem {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  background: #f0f7ff;
  border: 3px solid #bde0fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  box-shadow: 0 6px 16px rgba(2, 136, 209, 0.12);
  flex-shrink: 0;
}

.clan-dashboard-info {
  flex: 1;
}

.clan-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.clan-name-title {
  font-size: 22px;
  font-weight: 900;
  margin: 0;
}

.clan-description-text {
  color: var(--duo-gray-dark);
  font-size: 14px;
  margin: 0 0 14px 0;
  line-height: 1.45;
}

.clan-meta-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
}

.clan-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

/* Roster Table */
.clan-roster-container {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 0 var(--duo-gray-border);
}

.clan-roster-table {
  width: 100%;
  border-collapse: collapse;
}

.clan-roster-table th {
  background: #f8fafc;
  color: var(--duo-gray-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 18px;
  border-bottom: 2px solid var(--duo-gray-border);
  text-align: left;
}

.clan-roster-table td {
  padding: 14px 18px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  vertical-align: middle;
}

.clan-roster-table tr:last-child td {
  border-bottom: none;
}

.roster-rank-col {
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.roster-user-col {
  display: flex;
  align-items: center;
  gap: 10px;
}

.roster-avatar {
  font-size: 24px;
  line-height: 1;
}

.roster-username {
  font-weight: 800;
  color: #1a1a1a;
}

.role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.role-leader {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.role-member {
  background: #f1f5f9;
  color: #475569;
}

.roster-xp-col {
  text-align: right;
  font-weight: 800;
}

.my-clan-row {
  background: #f0fdf4 !important;
}

/* Empty State */
.clan-empty-state {
  background: #ffffff;
  border: 2px dashed var(--duo-gray-border);
  border-radius: 18px;
  padding: 48px 24px;
  text-align: center;
  max-width: 440px;
  margin: 20px auto;
}

/* Creation Modal Emblems */
.clan-modal-window {
  max-width: 480px !important;
}

.clan-emblem-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.clan-emblem-option {
  border: 2px solid var(--duo-gray-border);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
  user-select: none;
}
.clan-emblem-option:hover {
  background: #f0f7ff;
  border-color: var(--duo-blue);
}
.clan-emblem-option.selected {
  background: #eef8ff;
  border-color: var(--duo-blue);
  box-shadow: 0 0 0 2px var(--duo-blue);
}

.clan-emblem-icon {
  font-size: 26px;
  margin-bottom: 4px;
}

.clan-emblem-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--duo-gray-dark);
}

@media (max-width: 768px) {
  .clan-hero-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 16px;
  }
  .clan-hero-illustration {
    display: none;
  }
  .clan-section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .clan-search-box,
  #clan-search-input {
    width: 100% !important;
  }
  .clan-dashboard-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
    gap: 14px;
  }
  .clan-dashboard-main {
    flex-direction: column;
    align-items: flex-start;
  }
  .clan-cards-grid {
    grid-template-columns: 1fr;
  }
  .clan-emblem-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   FULL DUOLINGO PROFILE PAGE (VIEW-PROFILE)
   ========================================================================== */
.duo-profile-page {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 32px;
}

.duo-profile-guest-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 20px;
  padding: 48px 24px;
  text-align: center;
}

.duo-profile-banner {
  position: relative;
  border-radius: 20px;
  overflow: visible;
  margin-bottom: 46px;
}

.duo-profile-banner-bg {
  height: 165px;
  border-radius: 20px;
  background: linear-gradient(135deg, #38bdf8 0%, #bae6fd 60%, #fef3c7 100%);
  border: 2px solid #bae6fd;
  position: relative;
  overflow: hidden;
}

.duo-profile-banner-bg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.duo-profile-banner-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.duo-profile-banner-content {
  position: relative;
  padding-left: 28px;
}

.duo-profile-avatar-wrap {
  position: absolute;
  top: -58px;
  left: 28px;
  width: 112px;
  height: 112px;
  cursor: pointer;
}

.duo-profile-avatar-circle {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid #ffffff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.duo-profile-avatar-wrap:hover .duo-profile-avatar-circle {
  transform: scale(1.04);
}

.duo-profile-avatar-edit-btn {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.duo-profile-avatar-edit-btn:hover {
  transform: scale(1.1);
  border-color: var(--duo-blue);
}

.duo-profile-identity-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 6px;
  border-bottom: 2px solid var(--duo-gray-border);
  padding-bottom: 20px;
}

.duo-profile-name {
  font-size: 26px;
  font-weight: 900;
  color: var(--duo-text-dark);
  margin: 0 0 4px;
  line-height: 1.2;
}

.duo-profile-handle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 700;
  color: var(--duo-gray-dark);
  margin-bottom: 10px;
}

.duo-profile-handle {
  color: var(--duo-gray-text);
}

.duo-profile-grade {
  background: #eef8ff;
  color: var(--duo-blue-dark);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.duo-profile-badges-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.duo-profile-clan-pill {
  border: 2px solid #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.duo-profile-clan-pill:hover {
  background: #e0f2fe;
  transform: translateY(-1px);
}

.duo-profile-clan-pill.empty {
  border-color: var(--duo-gray-border);
  background: #ffffff;
  color: var(--duo-gray-dark);
}

.duo-profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.duo-profile-avatar-drawer {
  background: #ffffff;
  border: 2px solid var(--duo-blue);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(28, 176, 246, 0.12);
}

.duo-profile-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.duo-profile-section-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--duo-text-dark);
  margin: 0;
}

.duo-profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.duo-profile-stat-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s ease;
}

.duo-profile-stat-card:hover {
  border-color: #cbd5e1;
}

.duo-stat-icon-box {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.duo-stat-value {
  font-size: 20px;
  font-weight: 900;
  color: var(--duo-text-dark);
  line-height: 1.1;
}

.duo-stat-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--duo-gray-dark);
  margin-top: 2px;
}

.duo-profile-course-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 16px;
  padding: 16px 18px;
}

.duo-achievements-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.duo-achievement-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.duo-ach-badge {
  width: 66px;
  height: 76px;
  border-radius: 14px;
  border: 2px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  position: relative;
}

.duo-ach-emoji {
  font-size: 28px;
  line-height: 1;
}

.duo-ach-lvl {
  font-size: 10px;
  font-weight: 900;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.4px;
}

.duo-ach-body {
  flex: 1;
  min-width: 0;
}

.duo-ach-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.duo-ach-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--duo-text-dark);
}

.duo-ach-counter {
  font-size: 13px;
  font-weight: 800;
  color: var(--duo-gray-dark);
  white-space: nowrap;
}

.duo-ach-desc {
  font-size: 13px;
  font-weight: 600;
  color: var(--duo-gray-dark);
  margin-bottom: 10px;
}

.duo-ach-progress-track {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.duo-ach-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.duo-profile-security-box {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-radius: 16px;
  padding: 14px 18px;
}

@media (max-width: 768px) {
  .qazaq-toast-banner {
    max-width: calc(100vw - 24px);
    text-align: center;
    font-size: 13px;
    padding: 10px 18px;
  }
  .duo-profile-banner {
    margin-bottom: 42px;
  }
  .duo-profile-banner-bg {
    height: 120px;
  }
  .duo-profile-avatar-wrap {
    top: -48px;
    left: 16px;
    width: 96px;
    height: 96px;
  }
  .duo-profile-avatar-circle {
    width: 96px;
    height: 96px;
  }
  .duo-profile-identity-row {
    flex-direction: column;
    align-items: stretch;
  }
  .duo-profile-stats-grid {
    grid-template-columns: 1fr;
  }
  .duo-frames-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .duo-profile-actions {
    width: 100%;
  }
  .duo-profile-actions .duo-btn {
    flex: 1;
  }
}

/* ==========================================================================
   UNLOCKABLE PROFILE FRAMES (РАМКИ ПРОФИЛЯ ЗА УРОКИ)
   ========================================================================== */
.header-avatar-frame {
  padding: 2px;
  transition: transform 0.15s ease;
}

.frame-none {
  border-color: #ffffff !important;
}

.frame-baishashek {
  background: linear-gradient(135deg, #d9f99d, #6ee7b7) !important;
  border: 3px solid #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25), 0 6px 16px rgba(34, 197, 94, 0.22) !important;
}

.frame-shanyrak {
  background: linear-gradient(135deg, #e0f7fa, #fef08a) !important;
  border: 3px solid #00afca !important;
  box-shadow: 0 0 0 3px #fec50c, 0 6px 18px rgba(0, 175, 202, 0.28) !important;
}

.frame-alatau {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd) !important;
  border: 3px solid #0284c7 !important;
  box-shadow: 0 0 0 3px #7dd3fc, 0 6px 20px rgba(2, 132, 199, 0.3) !important;
}

.frame-altyn {
  background: linear-gradient(135deg, #fef9c3, #fde047) !important;
  border: 3px solid #eab308 !important;
  box-shadow: 0 0 0 3px #f59e0b, 0 6px 22px rgba(234, 179, 8, 0.38) !important;
}

.frame-tulpar {
  background: linear-gradient(135deg, #f3e8ff, #fde68a) !important;
  border: 3px solid #9333ea !important;
  box-shadow: 0 0 0 3px #f59e0b, 0 6px 24px rgba(147, 51, 234, 0.35) !important;
}

.frame-qazaq_star {
  background: linear-gradient(135deg, #dcfce7, #fef08a, #bae6fd) !important;
  border: 3px solid #10b981 !important;
  box-shadow: 0 0 0 3px #facc15, 0 0 18px rgba(16, 185, 129, 0.45) !important;
}

.duo-frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 12px;
}

.duo-frame-card {
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  border-bottom-width: 4px;
  border-radius: 16px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.duo-frame-card.unlocked:hover {
  transform: translateY(-2px);
  border-color: var(--duo-blue);
}

.duo-frame-card.selected {
  background: #eef8ff;
  border-color: var(--duo-blue);
}

.duo-frame-card.locked {
  opacity: 0.72;
  background: #f8fafc;
}

.duo-frame-preview {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--duo-gray-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.duo-frame-lock {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--duo-gray-border);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.duo-frame-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--duo-text-dark);
  text-align: center;
  line-height: 1.2;
}

.duo-frame-req {
  font-size: 11px;
  font-weight: 800;
  color: var(--duo-gray-dark);
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 999px;
}

.duo-frame-card.selected .duo-frame-req {
  background: var(--duo-blue);
  color: #ffffff;
}
