:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --font: 'Open Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: #f0f4ff;
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 17px;
  line-height: 1.65;
}

/* ---- TOP NAV ---- */
#topnav {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}
#topnav .logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#topnav .logo span { font-size: 1.4rem; }
#progress-bar-wrap {
  flex: 1;
  margin: 0 2rem;
  background: rgba(255,255,255,0.25);
  border-radius: 99px;
  height: 8px;
  max-width: 300px;
}
#progress-bar {
  height: 100%;
  background: #fff;
  border-radius: 99px;
  transition: width 0.4s;
  width: 0%;
}
#progress-label {
  font-size: 0.8rem;
  opacity: 0.9;
  white-space: nowrap;
}

/* ---- LAYOUT ---- */
#app {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* ---- SIDEBAR ---- */
#sidebar {
  width: 280px;
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 1.5rem 0;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.3s;
}
#sidebar h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
}
.unit-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--gray-700);
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.unit-btn:hover { background: var(--gray-50); }
.unit-btn.active {
  background: var(--primary-light);
  border-left-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
.unit-btn .badge {
  margin-left: auto;
  font-size: 0.7rem;
  background: var(--success-light);
  color: var(--success);
  border-radius: 99px;
  padding: 1px 8px;
  font-weight: 600;
}
.unit-btn .num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--gray-600);
}
.unit-btn.active .num {
  background: var(--primary);
  color: white;
}
.unit-btn.done .num {
  background: var(--success);
  color: white;
}

/* ---- MAIN ---- */
#main {
  flex: 1;
  padding: 2rem;
  max-width: 860px;
  overflow-y: auto;
}

/* ---- SECTION HEADER ---- */
.section-header {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.section-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}
.section-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2px;
}
.section-header p {
  font-size: 0.9rem;
  color: var(--gray-500);
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: white;
  border-radius: var(--radius-lg);
  padding: 6px;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.tab-btn {
  padding: 0.5rem 1.2rem;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--gray-500);
  transition: all 0.15s;
}
.tab-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

/* ---- CONTENT PANEL ---- */
.panel { display: none; }
.panel.active { display: block; }

/* ---- VOCAB CARD ---- */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.vocab-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  padding-top: 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}
.vocab-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}
.vocab-card .en-word {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;
  padding-right: 48px; /* make room for big speak button */
}
.vocab-card .phonetic {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-bottom: 8px;
  font-style: italic;
}
.vocab-card .sl-word {
  font-size: 0.88rem;
  color: var(--gray-600);
  background: var(--gray-100);
  border-radius: 6px;
  padding: 3px 8px;
  display: inline-block;
}
.vocab-card .example {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 8px;
  line-height: 1.4;
  font-style: italic;
  display: none;
}
.vocab-card.expanded .example { display: block; }

/* ---- SPEAK BUTTON – POVEČAN ---- */
.speak-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary-light);
  border: none;
  border-radius: 50%;
  width: 44px;        /* povečano z 32px */
  height: 44px;       /* povečano z 32px */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;  /* povečano z 0.9rem */
  transition: background 0.15s, transform 0.15s;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(37,99,235,0.15);
}
.speak-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.08);
}
.speak-btn.playing {
  background: var(--primary);
  color: white;
  animation: pulse 0.5s infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

/* ---- DIALOGUE ---- */
.dialogue-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.dialogue-box h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-100);
}
.line {
  display: flex;
  gap: 12px;
  margin-bottom: 1rem;
  align-items: flex-start;
}
.line .speaker {
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  background: var(--primary);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
  margin-top: 2px;
  flex-shrink: 0;
}
.line .speaker.b { background: var(--warning); }
.line-content { flex: 1; }
.line-en {
  font-size: 0.95rem;
  color: var(--gray-800);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.line-sl {
  font-size: 0.82rem;
  color: var(--gray-500);
  font-style: italic;
}
.inline-speak {
  background: none;
  border: 1.5px solid var(--primary-light);
  border-radius: 99px;
  padding: 3px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--primary);
  transition: all 0.15s;
  font-family: var(--font);
  font-weight: 600;
  white-space: nowrap;
}
.inline-speak:hover { background: var(--primary); color: white; border-color: var(--primary); }
.inline-speak.playing { background: var(--primary); color: white; animation: pulse 0.5s infinite alternate; }

/* ---- GRAMMAR ---- */
.grammar-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.grammar-box h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.75rem;
}

/* ---- GRAMMAR EXTRA – razširjena razlaga ---- */
.grammar-extra {
  background: #f0f7ff;
  border: 1.5px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.7;
}
.grammar-extra h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
  margin-top: 0.8rem;
}
.grammar-extra h4:first-child { margin-top: 0; }
.grammar-extra p {
  margin-bottom: 0.3rem;
}
.grammar-extra em {
  color: var(--primary-dark);
  font-style: normal;
  font-weight: 700;
}
.grammar-extra strong {
  color: var(--gray-800);
}
.grammar-example-box {
  background: white;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.65rem 1rem;
  margin-top: 0.8rem;
  font-size: 0.88rem;
  color: var(--gray-700);
  line-height: 1.7;
}

.grammar-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.grammar-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
}
.grammar-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.grammar-table tr:last-child td { border-bottom: none; }
.grammar-table .en { font-weight: 600; color: var(--gray-800); }
.grammar-table .sl { color: var(--gray-500); font-size: 0.82rem; }
.grammar-note {
  background: var(--warning-light);
  border-left: 4px solid var(--warning);
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  margin-top: 0.75rem;
  color: var(--gray-700);
  line-height: 1.6;
}
.grammar-note strong { color: var(--warning); }

/* ---- QUIZ ---- */
.quiz-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.quiz-question {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
}
.quiz-hint {
  font-size: 0.82rem;
  color: var(--gray-400);
  margin-bottom: 1rem;
  font-style: italic;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}
.quiz-opt {
  padding: 0.65rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  background: white;
  text-align: left;
  transition: all 0.15s;
  color: var(--gray-700);
}
.quiz-opt:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.quiz-opt.correct { border-color: var(--success); background: var(--success-light); color: var(--success); font-weight: 600; }
.quiz-opt.wrong { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }
.quiz-feedback {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  display: none;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.ok { background: var(--success-light); color: var(--success); }
.quiz-feedback.bad { background: var(--danger-light); color: var(--danger); }
#quiz-score {
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  display: none;
}
#quiz-score h3 { color: var(--primary-dark); font-size: 1.2rem; }
#quiz-score p { color: var(--gray-600); font-size: 0.9rem; margin-top: 4px; }

/* ---- PHRASEBOOK ---- */
.phrase-section { margin-bottom: 1.5rem; }
.phrase-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.phrase-item {
  background: white;
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.phrase-text { flex: 1; }
.phrase-en {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
}
.phrase-sl {
  font-size: 0.82rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ---- PHRASE SPEAK BUTTON – POVEČAN ---- */
.phrase-speak {
  background: var(--primary-light);
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;   /* povečano */
  cursor: pointer;
  font-size: 0.9rem;    /* povečano */
  color: var(--primary);
  font-weight: 700;
  font-family: var(--font);
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(37,99,235,0.1);
}
.phrase-speak:hover { background: var(--primary); color: white; transform: scale(1.04); }
.phrase-speak.playing { background: var(--primary); color: white; animation: pulse 0.5s infinite alternate; }

/* ---- NAV BUTTONS ---- */
.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  gap: 1rem;
}
.btn {
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: white;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- COMPLETION ---- */
.completion-banner {
  background: linear-gradient(135deg, var(--success-light), #bbf7d0);
  border: 2px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.2rem;
  text-align: center;
  margin-bottom: 1.15rem;
  display: none;
}
.completion-banner.show { display: block; }
.completion-banner h3 { color: var(--success); font-size: 1.12rem; margin-bottom: 4px; }
.completion-banner p { color: var(--gray-600); font-size: 0.84rem; }

/* ---- WORD TOOLTIP ---- */
.tooltip-word {
  cursor: pointer;
  border-bottom: 1px dashed var(--primary);
  color: var(--primary-dark);
  transition: background 0.15s;
  border-radius: 3px;
  padding: 0 2px;
}
.tooltip-word:hover { background: var(--primary-light); }


/* ---- PRONUNCIATION PANEL ---- */
.speak-section {
  margin-bottom: 1.5rem;
}
.speak-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.speak-item {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}
.speak-item.active-item {
  border-color: var(--primary);
}
.speak-item-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.speak-target {
  flex: 1;
  min-width: 0;
}
.speak-target-en {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 2px;
}
.speak-target-sl {
  font-size: 0.82rem;
  color: var(--gray-500);
  font-style: italic;
}
.speak-target-phonetic {
  font-size: 0.75rem;
  color: var(--gray-400);
  font-style: italic;
  margin-bottom: 2px;
}
.speak-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-listen {
  background: var(--primary-light);
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-listen:hover { background: var(--primary); color: white; }
.btn-listen.playing { background: var(--primary); color: white; animation: pulse 0.5s infinite alternate; }

.btn-record {
  background: var(--danger-light);
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--danger);
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-record:hover { background: var(--danger); color: white; }
.btn-record.recording {
  background: var(--danger);
  color: white;
  animation: recordPulse 0.8s infinite alternate;
}
@keyframes recordPulse {
  from { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  to   { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

/* Result bar */
.speak-result {
  margin-top: 0.75rem;
  display: none;
}
.speak-result.show { display: block; }
.speak-result-heard {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 0.4rem;
}
.speak-result-heard span {
  font-style: italic;
  color: var(--gray-700);
}
.score-bar-wrap {
  height: 10px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}
.score-bar-fill.great  { background: var(--success); }
.score-bar-fill.ok     { background: var(--warning); }
.score-bar-fill.poor   { background: var(--danger); }

.speak-feedback {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  display: inline-block;
}
.speak-feedback.great { background: var(--success-light); color: var(--success); }
.speak-feedback.ok    { background: var(--warning-light); color: var(--warning); }
.speak-feedback.poor  { background: var(--danger-light);  color: var(--danger); }

/* Word diff highlight */
.diff-correct { color: var(--success); font-weight: 700; }
.diff-wrong   { color: var(--danger);  font-weight: 700; text-decoration: underline wavy var(--danger); }

/* Mode toggle */
.speak-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.mode-btn {
  padding: 0.45rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: 99px;
  background: white;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--gray-500);
  transition: all 0.15s;
}
.mode-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.mode-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* Score summary */
.speak-summary {
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  text-align: center;
  margin-top: 1rem;
  display: none;
}
.speak-summary.show { display: block; }
.speak-summary h3 { color: var(--primary-dark); font-size: 1.1rem; }
.speak-summary p  { color: var(--gray-600); font-size: 0.88rem; margin-top: 4px; }

@media (max-width: 768px) {
  #sidebar { display: none; }
  #main { padding: 1rem; }
  .vocab-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  #topnav .logo span { display: none; }
  .speak-btn { width: 40px; height: 40px; font-size: 1.1rem; }
  .phrase-speak { padding: 8px 14px; font-size: 0.85rem; }
}

/* ============================================================
   TEST SISTEM
   ============================================================ */

/* Intro */
.test-intro {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.test-intro h2 { font-size: 1.3rem; margin-bottom: 0.5rem; color: var(--gray-900); }
.test-intro > p { font-size: 0.9rem; color: var(--gray-500); margin-bottom: 1.2rem; }

.test-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.test-mode-btn {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  cursor: pointer;
  font-family: var(--font);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.test-mode-btn .mode-icon { font-size: 1.4rem; }
.test-mode-btn strong { font-size: 0.88rem; color: var(--gray-800); }
.test-mode-btn small { font-size: 0.72rem; color: var(--gray-400); }
.test-mode-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.test-mode-btn.active { border-color: var(--primary); background: var(--primary-light); }
.test-mode-btn.active strong { color: var(--primary-dark); }

/* Progress */
.test-progress-bar-wrap {
  height: 6px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.test-progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.test-progress-label {
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-bottom: 1rem;
  text-align: right;
}

/* Question card */
.test-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.test-q-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.6rem;
}
.test-q-word {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.3rem;
}
.test-q-phonetic {
  font-size: 0.82rem;
  color: var(--gray-400);
  font-style: italic;
  margin-bottom: 1rem;
}
.test-q-example {
  margin-bottom: 1rem;
}

/* Multiple choice options */
.test-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.test-opt {
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  background: white;
  text-align: left;
  transition: all 0.15s;
  color: var(--gray-700);
}
.test-opt:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.test-opt.correct { border-color: var(--success); background: var(--success-light); color: var(--success); font-weight: 700; }
.test-opt.wrong   { border-color: var(--danger);  background: var(--danger-light);  color: var(--danger); }

/* Type input */
.test-type-wrap { display: flex; flex-direction: column; gap: 0.4rem; }
.test-type-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
.test-type-input:focus { border-color: var(--primary); }
.test-type-input.input-correct { border-color: var(--success); background: var(--success-light); }
.test-type-input.input-wrong   { border-color: var(--danger);  background: var(--danger-light); }

/* Feedback */
.test-feedback {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  display: none;
  line-height: 1.5;
}
.test-feedback.show { display: block; }
.test-feedback.ok  { background: var(--success-light); color: var(--success); }
.test-feedback.bad { background: var(--danger-light);  color: var(--danger); }

/* Match / Povezovanje */
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-top: 0.75rem;
}
.match-col {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.match-col-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  margin-bottom: 0.2rem;
  padding: 0 0.5rem;
}
.match-btn {
  padding: 0.8rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.92rem;
  background: white;
  text-align: left;
  transition: all 0.15s;
  color: var(--gray-700);
  word-break: break-word;
  min-height: 52px;
  display: flex;
  align-items: center;
  line-height: 1.35;
}
.left-btn { border-left: 4px solid var(--primary-light); }
.right-btn { border-left: 4px solid rgba(200,146,58,0.25); }
.match-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.match-btn.selected { border-color: var(--primary); background: var(--primary); color: white; border-left-width: 4px; }
.match-btn.matched-correct { border-color: var(--success); background: var(--success-light); color: var(--success); font-weight: 700; cursor: default; border-left-width: 4px; }
.match-btn.matched-wrong   { border-color: var(--danger);  background: var(--danger-light);  animation: shake 0.3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* Result */
.test-result-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.test-result-score {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}
.test-result-score.great { color: var(--success); }
.test-result-score.ok    { color: var(--warning); }
.test-result-score.poor  { color: var(--danger); }
.test-result-nums { font-size: 1.1rem; color: var(--gray-600); margin-bottom: 0.4rem; }
.test-result-msg  { font-size: 0.9rem; color: var(--gray-500); }

/* Wrong list */
.test-wrong-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
}
.test-wrong-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--gray-50);
}
.wrong-en     { font-weight: 700; color: var(--primary-dark); }
.wrong-sep    { color: var(--gray-400); }
.wrong-correct { font-weight: 700; color: var(--success); }
.wrong-yours  { color: var(--danger); font-size: 0.78rem; margin-left: auto; }

@media (max-width: 600px) {
  .test-mode-grid { grid-template-columns: 1fr 1fr; }
  .match-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .match-btn { font-size: 0.78rem; padding: 0.5rem 0.5rem; }
  .test-q-word { font-size: 1.3rem; }
}


body.welcome-open { overflow:hidden; }
#welcome-overlay { position:fixed; inset:0; background:rgba(15,23,42,0.7); backdrop-filter:blur(6px); display:none; align-items:center; justify-content:center; padding:1rem; z-index:4000; }
html.show-welcome #welcome-overlay { display:flex; }

.welcome-card { width:min(100%, 540px); background:white; border-radius:24px; padding:2rem; box-shadow:0 25px 80px rgba(0,0,0,0.22); }
.welcome-badge { display:inline-block; background:var(--primary-light); color:var(--primary-dark); border-radius:999px; padding:.45rem .8rem; font-size:.82rem; font-weight:700; margin-bottom:1rem; }
.welcome-card h2 { font-size:2rem; line-height:1.2; margin-bottom:.75rem; color:var(--gray-900); }
.welcome-lead { color:var(--gray-700); margin-bottom:1rem; }
.welcome-list { list-style:none; display:grid; gap:.7rem; margin:1rem 0 1.15rem; }
.welcome-list li { background:var(--gray-50); border:1px solid var(--gray-200); border-radius:12px; padding:.8rem .95rem; }
.welcome-note { color:var(--gray-600); margin-bottom:1.1rem; }
.welcome-actions { display:flex; gap:.75rem; flex-wrap:wrap; }
.welcome-btn-primary,.welcome-btn-secondary { border:none; border-radius:999px; padding:.9rem 1.2rem; font-family:var(--font); font-size:1rem; cursor:pointer; }
.welcome-btn-primary { background:var(--primary); color:#fff; font-weight:700; box-shadow:0 10px 24px rgba(37,99,235,.24); }
.welcome-btn-secondary { background:var(--gray-100); color:var(--gray-700); font-weight:600; }
.app-soft-intro { background:#eff6ff; color:var(--primary-dark); border-left:4px solid var(--primary); border-radius:12px; padding:.95rem 1rem; margin-bottom:1rem; }
@media (max-width: 700px){ .welcome-card{padding:1.35rem;border-radius:18px;} .welcome-card h2{font-size:1.55rem;} #progress-bar-wrap{display:none;} }

/* ============================================================
   GLOBAL SCALING IMPROVEMENTS
   ============================================================ */

/* Prevent horizontal overflow on mobile */
html, body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Make sure all images scale */
img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 480px) {
  /* Nav improvements */
  #topnav {
    padding: 0 0.75rem;
  }
  .nav-login-btn {
    font-size: 0.75rem !important;
    padding: 0.35rem 0.7rem !important;
  }

  /* Unit cards */
  .unit-card {
    padding: 1rem;
  }

  /* Section headings */
  .section-header h1 {
    font-size: 1.05rem !important;
  }

  /* Tabs — horizontal scroll */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; }

  /* Vocab grid single column on very small */
  .vocab-grid {
    grid-template-columns: 1fr !important;
  }

  /* Phrase list */
  .phrase-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .phrase-speak {
    align-self: flex-end;
  }

  /* Test cards */
  .test-card {
    padding: 1rem;
  }
  .test-q-word {
    font-size: 1.2rem;
  }

  /* Buttons full-width where sensible */
  .btn-row {
    flex-direction: column;
  }
  .btn-row .btn {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 400px) {
  .match-btn {
    font-size: 0.72rem !important;
    padding: 0.45rem 0.5rem !important;
  }
}
