/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:    #6366f1;
  --brand-dk: #4f46e5;
  --accent:   #f59e0b;
  --success:  #10b981;
  --danger:   #ef4444;
  --bg:       #f7f6ff;
  --surface:  #ffffff;
  --sidebar:  #1e1b4b;
  --sidebar-hover: rgba(255,255,255,0.08);
  --text:     #1e293b;
  --text-2:   #64748b;
  --border:   #e4e2f8;
  --radius:   14px;
  --radius-btn: 99px;
  --shadow:   0 2px 8px rgba(99,102,241,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:0 6px 16px rgba(99,102,241,.10), 0 2px 4px rgba(0,0,0,.04);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button, input { font-family: inherit; font-size: 1rem; }

/* ===================== LOGIN PAGE ===================== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 40%, #6366f1 100%);
}

.login-container { width: 100%; max-width: 480px; padding: 1.5rem; }

.login-logo { text-align: center; color: #fff; margin-bottom: 2rem; }
.login-logo h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -1px; }
.tagline { color: rgba(255,255,255,.65); margin-top: .25rem; }

.logo-de {
  display: inline-block;
  background: var(--accent);
  color: #1e1b4b;
  font-weight: 900;
  font-size: .85rem;
  padding: 2px 7px;
  border-radius: 6px;
  margin-bottom: .5rem;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 20px 48px rgba(30,27,75,.22), 0 4px 12px rgba(99,102,241,.12);
}
.login-card h2 { font-size: 1.1rem; color: var(--text-2); margin-bottom: 1.25rem; font-weight: 600; }

/* User grid */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .75rem; margin-bottom: .5rem; }

.user-card {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: .75rem .5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  background: none;
}
.user-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.user-card .avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.1rem; }
.user-card .uname { font-size: .8rem; font-weight: 600; color: var(--text); text-align: center; word-break: break-word; }

/* Divider */
.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--text-2); font-size: .85rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* OAuth section */
.login-oauth-hint { color: var(--text-2); font-size: .88rem; margin-bottom: 1.25rem; }
.login-oauth-btn-wrap { display: flex; justify-content: center; margin-top: .5rem; }

/* New user form */
.new-user-form { display: flex; flex-direction: column; gap: .6rem; }
.new-user-form input {
  width: 100%; padding: .65rem 1rem;
  border: 2px solid var(--border); border-radius: 99px;
  outline: none; transition: border-color .15s; font-size: .95rem;
}
.new-user-form input:focus { border-color: var(--brand); }
.new-user-form .btn { width: 100%; justify-content: center; }

/* Nickname setup extra spacing */
.nickname-setup .btn + .btn { margin-top: .25rem; }

/* ===================== APP LAYOUT ===================== */
.app-page { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--sidebar);
  display: flex; flex-direction: column;
  padding: 1.5rem 0;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 0 1.25rem 1.5rem;
  color: #fff; font-size: 1.1rem; font-weight: 800;
}
.brand-name { letter-spacing: -.5px; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: .25rem; padding: 0 .75rem; }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; border-radius: 8px;
  color: rgba(255,255,255,.6);
  font-size: .9rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(99,102,241,.4); }

.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: .5rem;
  color: rgba(255,255,255,.75);
  font-size: .85rem; font-weight: 600;
}
.sidebar-user .avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.logout-link { margin-left: auto; color: rgba(255,255,255,.4); font-size: 1.1rem; transition: color .15s; }
.logout-link:hover { color: #fff; }

.main-content { margin-left: 220px; flex: 1; padding: 2rem 2.5rem; min-height: 100vh; }

/* ===================== SHARED CARDS ===================== */
.card { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }

.page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.5rem; color: var(--text); }

/* ── Article quiz ── */
.article-quiz-word {
  font-size: 2rem; font-weight: 800;
  text-align: center; margin: 1.25rem 0 .35rem;
  letter-spacing: .01em;
}
.article-quiz-hint {
  text-align: center; color: var(--text-2);
  font-size: .95rem; margin-bottom: 1.5rem;
}
.article-quiz-btns {
  display: flex; gap: .75rem; justify-content: center;
}
.article-btn {
  padding: .65rem 2rem;
  font-size: 1.1rem; font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
  min-width: 90px;
}
.article-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); box-shadow: 0 4px 12px rgba(99,102,241,.2); }
.article-btn.correct { border-color: var(--success, #10b981); background: #d1fae5; color: #065f46; }
.article-btn.wrong   { border-color: var(--danger, #ef4444);  background: #fee2e2; color: #991b1b; }
.article-btn:disabled { cursor: default; }

/* ── Grammar filter bar ── */
.gr-filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem;
}
.gr-search-input {
  flex: 1; min-width: 180px;
  padding: .45rem .95rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: .93rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.gr-search-input:focus { outline: none; border-color: var(--brand); }
.gr-level-filters { display: flex; flex-wrap: wrap; gap: .4rem; }
.gr-lvl-btn {
  padding: .3rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text);
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.gr-lvl-btn:hover { border-color: var(--brand); color: var(--brand); }
.gr-lvl-btn.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.gr-no-results { color: var(--text-2); margin-top: 1rem; }
.section-title { font-size: 1rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }

/* ===================== BUTTONS ===================== */
.btn {
  padding: .55rem 1.3rem; border-radius: var(--radius-btn);
  font-weight: 600; cursor: pointer; border: none;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  display: inline-flex; align-items: center; gap: .4rem;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* Color modifiers — also apply pill shape so buttons work without the base .btn class */
.btn-primary, .btn-secondary, .btn-success, .btn-danger {
  border-radius: var(--radius-btn);
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; border: none; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dk); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: #fff; border: none; }
.btn-success:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.btn-danger  { background: var(--danger);  color: #fff; border: none; }
.btn-sm { padding: .35rem .85rem; font-size: .85rem; }

/* ===================== BADGE / LEVEL ===================== */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.badge-a1 { background: #dcfce7; color: #166534; }
.badge-a2 { background: #dbeafe; color: #1e40af; }
.badge-b1 { background: #fef9c3; color: #854d0e; }
.badge-b2 { background: #fce7f3; color: #9d174d; }

/* ===================== GRAMMAR VIEW ===================== */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.topic-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.25rem; cursor: pointer;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.topic-card:hover { border-color: var(--brand); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.topic-card.viewed { border-color: #c7d2fe; }
.topic-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .35rem; }
.topic-card p { font-size: .85rem; color: var(--text-2); line-height: 1.4; }
.topic-meta { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.view-count { font-size: .75rem; color: var(--text-2); }

/* Grammar topic detail */
.topic-detail { max-width: 1200px; }
.topic-detail .back-btn { margin-bottom: 1.25rem; }
.topic-detail h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: .5rem; }
.topic-detail .topic-header-meta { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.5rem; }

.topic-detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.75rem; align-items: start; }
.topic-detail-aside { position: sticky; top: 1.5rem; }
.gr-exercises-panel { padding: 1.25rem; }
.gr-exercises-panel-header { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text-1); border-bottom: 1px solid var(--border); padding-bottom: .6rem; }
@media (max-width: 900px) {
  .topic-detail-layout { grid-template-columns: 1fr; }
  .topic-detail-aside { position: static; }
}

.grammar-section { margin-bottom: 1.75rem; }
.grammar-section h2 { font-size: 1rem; font-weight: 700; color: var(--brand); margin-bottom: .75rem; padding-bottom: .35rem; border-bottom: 2px solid #e0e7ff; }
.grammar-section pre { white-space: pre-wrap; font-family: 'SF Mono', 'Fira Mono', monospace; font-size: .82rem; background: #f8fafc; padding: 1rem; border-radius: 8px; border: 1px solid var(--border); line-height: 1.65; }

.examples-table { width: 100%; border-collapse: collapse; }
.examples-table tr:nth-child(even) { background: #f8fafc; }
.examples-table td { padding: .5rem .75rem; font-size: .9rem; }
.examples-table td:first-child { font-weight: 600; color: var(--brand-dk); width: 50%; }

/* ===================== VOCABULARY VIEW ===================== */
.vocab-controls { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.5rem; }
.vocab-controls select, .vocab-controls input[type=number] {
  padding: .5rem .85rem; border: 2px solid var(--border); border-radius: 99px;
  background: var(--surface); outline: none; cursor: pointer;
  font-size: .9rem;
}
.vocab-controls select:focus, .vocab-controls input:focus { border-color: var(--brand); }

/* Exercise */
.exercise-card { max-width: 600px; }
.exercise-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.progress-label { font-size: .85rem; color: var(--text-2); }
.progress-bar-wrap { background: var(--border); border-radius: 99px; height: 6px; flex: 1; margin: 0 1rem; }
.progress-bar-fill { height: 6px; border-radius: 99px; background: var(--brand); transition: width .3s; }

.exercise-type-badge { display: flex; align-items: center; gap: .5rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin-bottom: .5rem; }
.exercise-prompt { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.5rem; line-height: 1.4; white-space: pre-wrap; }

/* Multiple choice */
.choices { display: grid; gap: .6rem; }
.choice-btn {
  padding: .8rem 1.1rem; border: 2px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer; text-align: left;
  font-size: .95rem; font-weight: 500;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice-btn:hover:not(:disabled) { border-color: var(--brand); background: #eef2ff; box-shadow: 0 2px 8px rgba(99,102,241,.15); }
.choice-btn.correct { border-color: var(--success); background: #d1fae5; color: #065f46; }
.choice-btn.wrong   { border-color: var(--danger);  background: #fee2e2; color: #991b1b; }
.choice-btn:disabled { cursor: default; }

/* Text input exercise */
.text-input-wrap { display: flex; flex-direction: column; gap: .75rem; }
.exercise-input {
  width: 100%; padding: .75rem 1rem;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 1.05rem; outline: none;
  transition: border-color .15s;
}
.exercise-input:focus { border-color: var(--brand); }
.exercise-input.correct { border-color: var(--success); background: #d1fae5; }
.exercise-input.wrong   { border-color: var(--danger);  background: #fee2e2; }

/* Feedback */
.feedback-box {
  margin-top: 1rem; padding: .9rem 1rem;
  border-radius: 10px; font-size: .9rem;
}
.feedback-box.correct { background: #d1fae5; color: #065f46; }
.feedback-box.wrong   { background: #fee2e2; color: #991b1b; }
.feedback-box .answer { font-weight: 700; }
.feedback-box .example { margin-top: .35rem; font-style: italic; color: inherit; opacity: .8; }

/* Session summary */
.summary-card { max-width: 480px; text-align: center; }
.summary-score { font-size: 3rem; font-weight: 900; color: var(--brand); margin: .5rem 0; }
.summary-label { color: var(--text-2); margin-bottom: 1.5rem; }
.summary-bar-wrap { background: var(--border); border-radius: 99px; height: 12px; margin: .5rem 0 1.5rem; }
.summary-bar-fill { height: 12px; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--success)); transition: width .6s ease; }

/* ===================== PROGRESS VIEW ===================== */
.progress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.stat-card { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 2rem; font-weight: 900; color: var(--brand); }
.stat-card .stat-label { font-size: .85rem; color: var(--text-2); }

.progress-topic-list { display: flex; flex-direction: column; gap: .5rem; }
.progress-topic-row {
  display: flex; flex-direction: column; gap: .35rem;
  padding: .6rem .9rem; border-radius: 8px; background: var(--surface);
  box-shadow: var(--shadow);
}
.progress-topic-row.clickable-row { cursor: pointer; transition: background .15s; }
.progress-topic-row.clickable-row:hover { background: var(--border); }
.progress-topic-main { display: flex; align-items: center; gap: .5rem; }
.progress-topic-row .topic-name { flex: 1; font-size: .9rem; font-weight: 600; }
.progress-topic-row .topic-views { font-size: .8rem; color: var(--text-2); }
.progress-topic-row .unread { color: #94a3b8; font-style: italic; font-size: .8rem; }
.progress-topic-row .progress-bar-wrap { margin: 0; }

/* ── Grammar exercise spinner ─────────────────────────────────────────── */
.gr-spinner-wrap { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; color: var(--text-2); font-size: .9rem; }
.gr-spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: gr-spin .7s linear infinite; flex-shrink: 0; }
@keyframes gr-spin { to { transform: rotate(360deg); } }

/* ── Grammar exercises ───────────────────────────────────────────────── */
.gr-exercises-wrap { display: flex; flex-direction: column; gap: 1.25rem; margin-top: .5rem; }
.gr-ex-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem; }
.gr-ex-question { font-size: .95rem; margin-bottom: .75rem; line-height: 1.5; }
.gr-ex-options { display: flex; flex-direction: column; gap: .45rem; }
.gr-ex-opt {
  text-align: left; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; padding: .55rem .9rem; font-size: .9rem; cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.gr-ex-opt:hover:not(:disabled) { border-color: var(--brand); background: #ede9fe; box-shadow: 0 2px 6px rgba(99,102,241,.15); }
.gr-ex-opt.selected { border-color: var(--brand); background: #ede9fe; }
.gr-ex-opt.gr-opt-correct { border-color: #16a34a; background: #dcfce7; color: #14532d; }
.gr-ex-opt.gr-opt-wrong   { border-color: var(--danger); background: #fee2e2; color: #7f1d1d; }
.gr-ex-opt:disabled { cursor: default; }
.gr-ex-explanation {
  margin-top: .75rem; padding: .5rem .75rem; border-radius: 6px;
  background: #f0fdf4; border-left: 3px solid #16a34a;
  font-size: .85rem; color: #166534;
}
.gr-ex-score { font-size: 1.05rem; font-weight: 700; color: var(--brand); margin-bottom: .25rem; }

/* ── Grammar topic chat ───────────────────────────────────────────────── */
.gr-topic-chat { margin-top: 1.5rem; padding: 0; overflow: hidden; }
.gr-topic-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem; cursor: pointer; user-select: none;
  font-weight: 600; font-size: .95rem;
  border-bottom: 1px solid transparent; transition: background .15s;
}
.gr-topic-chat-header:hover { background: var(--surface-2, #f1f5f9); }
.gr-topic-chat-header .gr-chat-chevron { font-size: .8rem; color: var(--text-2); }
.gr-topic-chat-body {
  flex-direction: column; gap: .75rem; padding: 1rem 1.1rem;
  border-top: 1px solid var(--border);
}
.gr-chat-messages {
  display: flex; flex-direction: column; gap: .6rem;
  max-height: 320px; overflow-y: auto;
  padding-right: .25rem;
}
.gr-chat-msg {
  max-width: 80%; padding: .55rem .8rem; border-radius: 10px;
  font-size: .9rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.gr-chat-msg-user {
  align-self: flex-end;
  background: var(--brand); color: #fff; border-bottom-right-radius: 3px;
}
.gr-chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface-2, #f1f5f9); color: var(--text-1);
  border: 1px solid var(--border); border-bottom-left-radius: 3px;
}
.gr-chat-input-wrap { display: flex; gap: .5rem; margin-top: .25rem; }
.gr-chat-input-wrap .exercise-input { flex: 1; }

.category-stat { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.category-name { width: 90px; font-size: .85rem; font-weight: 600; color: var(--text-2); text-transform: capitalize; }
.cat-bar-wrap { flex: 1; background: var(--border); border-radius: 99px; height: 8px; }
.cat-bar-fill { height: 8px; border-radius: 99px; background: var(--brand); }
.cat-pct { font-size: .8rem; color: var(--text-2); width: 40px; text-align: right; }

/* ===================== LOADING / EMPTY STATES ===================== */
.loading-dots { display: flex; gap: .4rem; align-items: center; justify-content: center; padding: 1rem; }
.loading-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); animation: pulse 1.2s infinite; }
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-2); }
.empty-state p { margin-top: .5rem; font-size: .95rem; }

/* ===================== VOCABULARY TABS ===================== */
.vocab-tabs-wrap { display: flex; gap: .5rem; margin-bottom: .25rem; }
.vocab-tab {
  padding: .45rem 1.1rem; border-radius: 8px 8px 0 0;
  border: 2px solid var(--border); border-bottom: none;
  background: var(--bg); color: var(--text-2);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.vocab-tab:hover { background: var(--surface); color: var(--text); }
.vocab-tab.active { background: var(--surface); color: var(--brand); border-color: var(--brand); }

/* ===================== VOCABULARY SESSION LAYOUT ===================== */
.session-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}
.exercise-area { min-width: 0; }

/* Answered panel */
.answered-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  position: sticky;
  top: 1.5rem;
}
.answered-panel-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-2);
  margin-bottom: .75rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.answered-list { display: flex; flex-direction: column; gap: .4rem; }
.answered-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: .4rem;
  padding: .4rem .5rem;
  border-radius: 6px;
  font-size: .82rem;
}
.answered-item.correct { background: #d1fae5; }
.answered-item.wrong   { background: #fee2e2; }
.answered-icon { font-weight: 700; text-align: center; font-size: .85rem; }
.answered-item.correct .answered-icon { color: var(--success); }
.answered-item.wrong   .answered-icon { color: var(--danger); }
.answered-word { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.answered-trans { color: var(--text-2); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== WORD BROWSER ===================== */
.browse-controls { display: flex; flex-wrap: wrap; gap: .75rem; }
.browse-controls select {
  padding: .5rem .85rem; border: 2px solid var(--border); border-radius: 99px;
  background: var(--surface); outline: none; cursor: pointer; font-size: .9rem;
}
.browse-controls select:focus { border-color: var(--brand); }
.browse-search-input {
  padding: .5rem .85rem; border: 2px solid var(--border); border-radius: 99px;
  background: var(--surface); outline: none; font-size: .9rem; width: 200px;
}
.browse-search-input:focus { border-color: var(--brand); }

.browse-category { margin-bottom: 2rem; }
.browse-cat-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: .75rem;
}
.browse-cat-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.browse-cat-count { font-size: .8rem; color: var(--text-2); }

.browse-word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .6rem;
}
/* ── Word lookup panel ────────────────────────────────────────────────── */
.lookup-input-row { display: flex; gap: .5rem; }
.lookup-input-row .exercise-input { flex: 1; }
.lookup-result-card { padding: 1rem; background: var(--surface-2, #f8fafc); border: 1px solid var(--border); border-radius: 10px; }
.lookup-correction { font-size: .85rem; color: var(--danger); margin-bottom: .5rem; }
.lookup-word-de { font-size: 1.4rem; font-weight: 700; color: var(--text-1); margin-bottom: .2rem; }
.lookup-translation { font-size: 1rem; color: var(--text-2); margin-bottom: .5rem; }
.lookup-meta { display: flex; gap: .5rem; align-items: center; }
.lookup-gender { font-size: .78rem; font-weight: 600; color: var(--brand); background: #ede9fe; border-radius: 4px; padding: .1rem .45rem; }

.browse-word-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem;
  box-shadow: var(--shadow);
}
.browse-german { font-size: 1rem; font-weight: 700; color: var(--brand-dk); }
.browse-plural { font-size: .75rem; color: var(--text-2); font-weight: 400; }
.browse-translation { font-size: .85rem; color: var(--text); margin: .2rem 0 .4rem; }
.browse-meta { display: flex; align-items: center; gap: .4rem; }
.browse-pos { font-size: .72rem; color: var(--text-2); text-transform: capitalize; }

/* Pending enrichment state */
.pending-banner {
  display: flex; align-items: center; gap: .75rem;
  background: #fef9c3; border: 1px solid #fde047;
  border-radius: 8px; padding: .6rem 1rem;
  font-size: .85rem; color: #713f12;
  margin-bottom: 1rem;
}
.browse-word-card.pending {
  opacity: .55;
  background: repeating-linear-gradient(
    135deg, var(--surface), var(--surface) 8px, #f8fafc 8px, #f8fafc 16px
  );
}
.pending-badge {
  font-size: .75rem; color: var(--text-2); font-style: italic;
}

/* Verb conjugation inside word card */
.browse-word-card.has-forms { grid-column: span 1; }
.verb-forms {
  margin-top: .6rem;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
}
.verb-forms summary {
  font-size: .75rem; font-weight: 700; color: var(--brand);
  cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; gap: .3rem;
}
.verb-forms summary::before { content: '▶'; font-size: .6rem; transition: transform .15s; }
.verb-forms[open] summary::before { transform: rotate(90deg); }
.conj-table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .8rem; }
.conj-table td { padding: .18rem .3rem; }
.conj-table td:first-child { color: var(--text-2); width: 60px; }
.conj-table td:last-child { font-weight: 600; color: var(--brand-dk); }
.verb-form-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; padding: .2rem 0; border-top: 1px solid var(--border);
  margin-top: .25rem;
}
.verb-form-row span { color: var(--text-2); }
.verb-form-row strong { color: var(--brand-dk); }

/* ===================== МОЙ СЛОВАРЬ ===================== */
.mw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
}

/* <details> card */
.mw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mw-card[open] { border-color: var(--brand); }

/* hide the default disclosure triangle */
.mw-card > summary { list-style: none; }
.mw-card > summary::-webkit-details-marker { display: none; }

.mw-summary {
  padding: .85rem 1rem;
  cursor: pointer;
  user-select: none;
}
.mw-summary:hover { background: var(--hover, rgba(0,0,0,.03)); }

.mw-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}

.mw-de { font-size: 1rem; font-weight: 700; color: var(--brand-dk); margin-bottom: .2rem; }
.mw-ru { font-size: .9rem; color: var(--text); }
.mw-context { font-size: .78rem; color: var(--text-2); font-style: italic; margin-top: .3rem; }
.mw-remove { flex-shrink: 0; padding: .2rem .5rem; font-size: .75rem; }

/* Expanded grammar detail pane */
.mw-detail {
  padding: .75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg, #f8fafc);
}

.mw-forms-loading { color: var(--text-2); font-size: .85rem; font-style: italic; display: flex; align-items: center; gap: .4rem; }
@keyframes mw-blink { 0%,100%{opacity:1} 50%{opacity:.2} }
.mw-loading-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: mw-blink 1.2s infinite; }

.mw-forms-subtitle { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: .35rem; }

.mw-form-row { display: flex; justify-content: space-between; gap: .5rem; font-size: .88rem; padding: .25rem 0; border-bottom: 1px solid var(--border); }
.mw-form-row:last-child { border-bottom: none; }
.mw-form-row span { color: var(--text-2); }
.mw-form-row strong { color: var(--text); }

.mw-conj-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.mw-conj-table td { padding: .2rem .4rem; border-bottom: 1px solid var(--border); }
.mw-conj-table td:first-child { color: var(--text-2); width: 45%; }
.mw-conj-table td:last-child { font-weight: 600; color: var(--text); }
.mw-conj-table tr:last-child td { border-bottom: none; }

.mw-conj-past td:first-child { color: var(--text-2); }

.mw-forms-other { color: var(--text-2); font-size: .82rem; padding-top: .3rem; }

/* ===================== МОЙ СЛОВАРЬ — УПРАЖНЕНИЯ ===================== */
.ex-setup { max-width: 480px; }
.ex-setup-group { margin-bottom: 1.1rem; }
.ex-setup-label { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: .45rem; }
.ex-radio-label { display: flex; align-items: center; gap: .5rem; font-size: .93rem; cursor: pointer; padding: .25rem 0; }
.ex-radio-label input { accent-color: var(--brand); width: 15px; height: 15px; }
.ex-range { width: 100%; accent-color: var(--brand); margin-top: .35rem; }

.ex-progress-wrap { height: 5px; background: var(--border); border-radius: 3px; margin-bottom: .75rem; overflow: hidden; }
.ex-progress-bar  { height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s; }

.ex-meta { font-size: .85rem; color: var(--text-2); margin-bottom: .85rem; }

.ex-card { max-width: 560px; padding: 1.5rem; }
.ex-question { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: 1.25rem; text-align: center; }

.ex-options { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.ex-option {
  padding: .65rem .75rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: .92rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  white-space: normal;
  word-break: break-word;
}
.ex-option:hover:not(:disabled) { border-color: var(--brand); background: #ede9fe; box-shadow: 0 2px 8px rgba(99,102,241,.15); }
.ex-option--correct { border-color: #16a34a !important; background: #dcfce7 !important; color: #15803d !important; font-weight: 600; }
.ex-option--wrong   { border-color: var(--danger) !important; background: #fee2e2 !important; color: #b91c1c !important; }

.ex-text-form { display: flex; gap: .6rem; align-items: center; }
.ex-text-input {
  flex: 1; padding: .6rem .85rem;
  border: 2px solid var(--border); border-radius: 8px;
  font-size: 1rem; font-family: inherit; outline: none;
  transition: border-color .15s;
}
.ex-text-input:focus { border-color: var(--brand); }
.ex-text-input:disabled { opacity: .7; }
.ex-input--correct { border-color: #16a34a !important; background: #dcfce7; }
.ex-input--wrong   { border-color: var(--danger) !important; background: #fee2e2; }

.ex-feedback {
  margin-top: 1rem; padding: .55rem .85rem;
  border-radius: 8px; font-size: .93rem; font-weight: 600;
}
.ex-feedback--correct { background: #dcfce7; color: #15803d; }
.ex-feedback--wrong   { background: #fee2e2; color: #b91c1c; }

.ex-next-btn { margin-top: .75rem; }

.ex-summary { max-width: 360px; margin: 2rem auto; text-align: center; padding: 2rem; }
.ex-summary-score { font-size: 3rem; font-weight: 800; color: var(--brand); line-height: 1; }
.ex-summary-score span { font-size: 1.5rem; color: var(--text-2); font-weight: 400; }
.ex-summary-pct { font-size: 1.1rem; color: var(--text-2); margin: .3rem 0 1rem; }
.ex-summary-msg { margin-bottom: 1.25rem; font-size: .95rem; }

/* ===================== ТЕКСТОН ===================== */
.tt-textarea {
  width: 100%; padding: .75rem 1rem;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit;
  resize: vertical; outline: none;
  transition: border-color .15s;
}
.tt-textarea:focus { border-color: var(--brand); }

.tt-text-block {
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text);
}
.tt-word {
  display: inline;
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 1px;
  transition: background .1s;
}
.tt-word:hover { background: #dbeafe; color: var(--brand-dk); }

/* Tooltip */
.trans-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 10px;
  padding: .6rem .85rem;
  min-width: 140px;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: auto;
}
.tt-tip-word { font-size: .95rem; font-weight: 700; margin-bottom: .25rem; }
.tt-tip-trans { font-size: 1rem; font-weight: 600; color: #f8fafc; margin-bottom: .5rem; }
.tt-tip-loading { font-size: .82rem; color: #94a3b8; margin-bottom: .5rem; font-style: italic; }
.tt-tip-add { width: 100%; margin-top: .35rem; font-size: .82rem; padding: .35rem .7rem; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand .brand-name, .nav-item span, .sidebar-user span { display: none; }
  .nav-item { justify-content: center; }
  .main-content { margin-left: 60px; padding: 1rem; }
  .topics-grid { grid-template-columns: 1fr; }
  .session-layout { grid-template-columns: 1fr; }
  .answered-panel { position: static; max-height: 250px; }
}

/* ===================== ЧАТ ===================== */
.chat-layout {
  display: flex;
  height: calc(100vh - 2rem);
  gap: 1rem;
  overflow: hidden;
}

.chat-sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  overflow: hidden;
}

.chat-new-options {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.chat-new-btn {
  width: 100%;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  justify-content: center;
}

.chat-new-icon {
  font-size: 1rem;
}

.chat-mode-banner {
  border-radius: 8px;
  padding: .6rem 1rem;
  font-size: .85rem;
  margin-bottom: .5rem;
  line-height: 1.4;
}

.chat-mode-banner--topic {
  background: #fef9c3;
  color: #713f12;
  border: 1px solid #fde68a;
}

.chat-mode-banner--free {
  background: #f0fdf4;
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.chat-list-empty {
  color: var(--text-2);
  font-size: .85rem;
  text-align: center;
  padding-top: 1rem;
}

.chat-list-item {
  padding: .6rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s;
}
.chat-list-item:hover { background: var(--hover, #f1f5f9); }
.chat-list-item.active { background: #ede9fe; border-color: var(--brand); }

.chat-list-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-date { font-size: .75rem; color: var(--text-2); margin-top: .15rem; }

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 1rem;
}

.chat-prompt-card {
  flex-shrink: 0;
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 10px;
  padding: .75rem 1rem;
  margin-bottom: .75rem;
}
.chat-prompt-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #854d0e;
  margin-bottom: .25rem;
}
.chat-prompt-text { font-size: .9rem; color: #713f12; line-height: 1.5; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding-right: .25rem;
  padding-bottom: .5rem;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}
.chat-message--user { align-self: flex-end; align-items: flex-end; }
.chat-message--assistant { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: .65rem .9rem;
  border-radius: 14px;
  font-size: .92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-message--user .chat-bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message--assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-correction {
  margin-top: .35rem;
  font-size: .82rem;
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: .35rem .65rem;
  max-width: 100%;
  line-height: 1.5;
}
.chat-correction-label {
  font-weight: 700;
  margin-right: .3rem;
}

.chat-input-row {
  flex-shrink: 0;
  display: flex;
  gap: .6rem;
  align-items: flex-end;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}

.chat-textarea {
  flex: 1;
  padding: .65rem .85rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color .15s;
  line-height: 1.5;
}
.chat-textarea:focus { border-color: var(--brand); }

.chat-send-btn {
  height: 44px;
  padding: 0 1.5rem;
  flex-shrink: 0;
  border-radius: 99px;
}

/* ===================== HÖRVERSTEHEN ===================== */
.hoer-page { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem; }
.hoer-header { margin-bottom: 1.5rem; }
.hoer-title { font-size: 1.6rem; font-weight: 700; }
.hoer-subtitle { color: var(--text-2); margin-top: .25rem; }

/* Setup card */
.hoer-setup-card { padding: 1.5rem; }
.hoer-setup-card h2 { font-size: 1.15rem; margin-bottom: .35rem; }
.hoer-topic-row { display: flex; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }
.hoer-input {
  flex: 1; min-width: 180px;
  padding: .55rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.hoer-input:focus { border-color: var(--brand); }
.hoer-gen-btn { white-space: nowrap; }
.hoer-error { color: var(--danger); margin-top: .5rem; font-size: .9rem; }
.hoer-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* History list */
.hoer-hist-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: .65rem .8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.hoer-hist-item:hover { background: var(--bg); }
.hoer-hist-date { font-size: .82rem; margin-left: .5rem; }
.hoer-score-badge {
  background: var(--brand);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
}
.hoer-score-badge.new { background: var(--text-2); }

/* Exercise card */
.hoer-exercise-card { padding: 1.5rem; }
.hoer-ex-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.hoer-ex-header h2 { font-size: 1.1rem; font-weight: 700; }
.hoer-back-btn {
  background: none; border: none; color: var(--brand);
  cursor: pointer; font-size: .9rem; padding: 0;
}
.hoer-back-btn:hover { text-decoration: underline; }

/* Audio player */
.hoer-player-wrap { margin-bottom: 1.25rem; }
.hoer-audio { width: 100%; border-radius: 8px; }

/* Questions */
.hoer-question {
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.hoer-question:last-child { border-bottom: none; }
.hoer-stmt { font-size: .97rem; margin-bottom: .5rem; }
.hoer-rf-btns { display: flex; gap: .5rem; }
.hoer-rf-btn {
  padding: .35rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  cursor: pointer;
  font-size: .9rem;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.hoer-rf-btn:hover { border-color: var(--brand); }
.hoer-rf-btn.selected { border-color: var(--brand); background: #eef2ff; color: var(--brand); font-weight: 600; box-shadow: 0 2px 8px rgba(99,102,241,.18); }

/* Wort-Wahl (fill-in-the-blank) */
.hoer-ww-question { background: #fafafa; border-radius: 8px; padding: .75rem; }
.hoer-ww-label { margin-bottom: .6rem; }
.hoer-ww-opts { display: flex; flex-wrap: wrap; gap: .5rem; }
.hoer-ww-btn {
  padding: .35rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  cursor: pointer;
  font-size: .9rem;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.hoer-ww-btn:hover { border-color: var(--brand); }
.hoer-ww-btn.selected { border-color: var(--brand); background: #eef2ff; color: var(--brand); font-weight: 600; box-shadow: 0 2px 8px rgba(99,102,241,.18); }

.hoer-q-num { color: var(--text-2); font-size: .85rem; margin-right: .3rem; }
.hoer-q-correct .hoer-stmt { color: var(--success); }
.hoer-q-wrong   .hoer-stmt { color: var(--danger); }
.hoer-correct-label { font-size: .83rem; color: var(--text-2); margin-top: .25rem; }

.hoer-submit-btn { margin-top: 1.25rem; width: 100%; }

/* Result box */
.hoer-result-box {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.25rem;
  border-radius: 10px;
  margin-top: 1rem;
}
.result-great { background: #d1fae5; color: #065f46; }
.result-ok    { background: #fef9c3; color: #78350f; }
.result-poor  { background: #fee2e2; color: #991b1b; }
.hoer-result-score { font-size: 1.4rem; font-weight: 800; }
.hoer-result-pct   { font-size: 1rem; }

/* Transcript */
.hoer-transcript-wrap { margin-top: 1.25rem; }
.hoer-reveal-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: .4rem 1.1rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-2);
  transition: border-color .15s, color .15s;
}
.hoer-reveal-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.hoer-reveal-btn:disabled { opacity: .5; cursor: default; }
.hoer-transcript {
  margin-top: .75rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: .95rem;
  line-height: 1.9;
}
.hoer-transcript-hint {
  font-size: .78rem;
  color: var(--text-2);
  margin-bottom: .6rem;
}
.hoer-prev-score { margin-top: 1rem; font-size: .85rem; }

/* ── My Words — translate pane ── */
.mw-translate-card { padding: 1.25rem; max-width: 700px; }
.mw-translate-row { display: flex; gap: .75rem; align-items: flex-start; }
.mw-translate-row .tt-textarea { flex: 1; }
.mw-tr-result { margin-top: 1.25rem; }
.mw-tr-label { font-size: .8rem; color: var(--text-2); margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .05em; }
.mw-tr-hint { font-size: .78rem; color: var(--text-2); margin-top: .6rem; }
.mw-tr-result .tt-text-block { font-size: 1rem; line-height: 1.9; }

/* ══════════════════════════════════════════════════════════
   Exam B1 module
   ══════════════════════════════════════════════════════════ */

/* ── Page shell ── */
.exam-page { max-width: 820px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ── Home ── */
.exam-home-header { margin-bottom: 1.5rem; }
.exam-home-header h2 { margin: 0 0 .25rem; }
.exam-home-header p  { margin: 0; color: var(--text-2); font-size: .95rem; }
.exam-home-btns { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.75rem; }

/* attempt history */
.exam-hist-list { display: flex; flex-direction: column; gap: .75rem; }
.exam-hist-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s;
}
.exam-hist-item:hover { border-color: var(--brand); }
.exam-hist-meta { font-size: .83rem; color: var(--text-2); }
.exam-hist-score { font-weight: 700; font-size: 1.05rem; }
.exam-hist-info { flex: 1; }
.exam-del-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: .9rem; padding: .25rem .4rem;
  border-radius: 5px; line-height: 1; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.exam-del-btn:hover { color: var(--danger, #ef4444); background: #fee2e2; }

/* ── Section list ── */
.exam-section-header { margin-bottom: 1.25rem; }
.exam-section-header h2 { margin: 0 0 .2rem; }
.exam-group { margin-bottom: 1.5rem; }
.exam-group-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-2); margin-bottom: .6rem; font-weight: 600;
}
.exam-section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.exam-sec-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: .85rem 1rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.exam-sec-card:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(99,102,241,.1); }
.exam-sec-card.done { border-color: var(--success, #10b981); }
.exam-sec-name { font-weight: 600; font-size: .95rem; margin-bottom: .35rem; }
.exam-sec-score { font-size: .85rem; color: var(--text-2); }

/* badge */
.exam-badge {
  display: inline-block;
  font-size: .72rem; padding: .15rem .5rem;
  border-radius: 99px; font-weight: 600;
  margin-left: .5rem;
}
.exam-badge-done { background: #d1fae5; color: #065f46; }
.exam-badge-prog { background: #fef9c3; color: #78350f; }

/* total score bar */
.exam-total-score {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.exam-total-label { font-weight: 600; flex: 1; min-width: 120px; }
.exam-total-num { font-size: 1.5rem; font-weight: 800; }
.exam-total-pct { font-size: .9rem; color: var(--text-2); }
.exam-total-bar { width: 100%; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.exam-total-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }
.pass { color: var(--success, #10b981); }
.fail { color: var(--danger, #ef4444); }

/* ── Section shell (instructions + submit) ── */
.exam-section-shell { padding-bottom: 2rem; }
.exam-section-shell h2 { margin: 0 0 .25rem; }
.exam-instructions {
  background: #eef2ff; border-radius: 8px; padding: .75rem 1rem;
  margin-bottom: 1.25rem; font-size: .93rem; color: #3730a3;
}
.exam-submit-row { margin-top: 1.5rem; }

/* ── Audio player ── */
.exam-audio-wrap {
  margin-bottom: 1.25rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.exam-audio-wrap audio { flex: 1; min-width: 200px; }

/* ── Lesen 1 (headline matching) ── */
.exam-headlines {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1.25rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.exam-hl-item { font-size: .85rem; }
.exam-hl-item strong { display: inline-block; min-width: 1.5rem; }

.exam-lv1-list { display: flex; flex-direction: column; gap: .75rem; }
.exam-lv1-row {
  display: grid; grid-template-columns: 2rem 1fr auto;
  gap: .75rem; align-items: start;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.exam-lv1-num { font-weight: 700; padding-top: .1rem; }
.exam-lv1-text { font-size: .92rem; line-height: 1.6; }
.exam-lv1-sel { padding: .35rem .5rem; border: 1.5px solid var(--border); border-radius: 6px; font-size: .9rem; }

/* ── Lesen 2 (multiple choice) ── */
.exam-reading-text {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .93rem; line-height: 1.7;
  white-space: pre-line;
}
.exam-mc-list { display: flex; flex-direction: column; gap: 1rem; }
.exam-mc-q { padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.exam-mc-stem { font-weight: 600; margin-bottom: .6rem; font-size: .93rem; }
.exam-mc-opt { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; padding: .2rem 0; font-size: .9rem; }
.exam-mc-opt input { margin-top: .2rem; }

/* ── Lesen 3 (situation → ad matching) ── */
.exam-lv3-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 640px) { .exam-lv3-layout { grid-template-columns: 1fr; } }
.exam-lv3-panel-title { font-weight: 700; margin-bottom: .75rem; font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.exam-sit-row {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .6rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .5rem;
  font-size: .88rem;
}
.exam-sit-num { font-weight: 700; min-width: 1.5rem; }
.exam-sit-sel { margin-left: auto; padding: .25rem .4rem; border: 1.5px solid var(--border); border-radius: 6px; font-size: .88rem; }
.exam-ad-item {
  padding: .6rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .5rem;
  font-size: .88rem;
  line-height: 1.5;
}
.exam-ad-letter { font-weight: 700; margin-bottom: .2rem; color: var(--brand); }

/* ── Sprachbausteine 1 (inline fill) ── */
.exam-fill-text {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .93rem; line-height: 2.2;
}
.exam-inline-sel {
  padding: .15rem .4rem;
  margin: 0 .15rem;
  border: 1.5px solid var(--brand);
  border-radius: 5px;
  font-size: .88rem;
  background: #eef2ff;
  color: var(--brand);
}

/* ── Sprachbausteine 2 (word list) ── */
.exam-wordlist {
  display: flex; flex-wrap: wrap; gap: .5rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.exam-wl-item {
  font-size: .85rem;
  padding: .2rem .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ── Hörverstehen (exam) ── */
.exam-hv-list { display: flex; flex-direction: column; gap: .6rem; }
.exam-hv-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
}
.exam-hv-num { font-weight: 700; min-width: 1.5rem; color: var(--text-2); }
.exam-hv-text { flex: 1; line-height: 1.5; }
.exam-hv-btns { display: flex; gap: .4rem; flex-shrink: 0; }
.exam-hv-btn {
  padding: .25rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  cursor: pointer;
  font-size: .85rem;
  transition: border-color .15s, background .15s;
}
.exam-hv-btn:hover { border-color: var(--brand); }
.exam-hv-btn.selected { border-color: var(--brand); background: #eef2ff; color: var(--brand); font-weight: 600; }

/* ── Schreiben ── */
.exam-schreiben-email {
  padding: 1rem 1.25rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: .9rem; line-height: 1.7;
  white-space: pre-line;
}
.exam-email-label { font-weight: 700; color: var(--brand); margin-bottom: .4rem; }
.exam-schreiben-card {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.exam-key-points { margin: .5rem 0 0 1.2rem; padding: 0; font-size: .9rem; }
.exam-key-points li { margin-bottom: .25rem; }
.exam-wc { font-size: .78rem; color: var(--text-2); margin-top: .35rem; text-align: right; }

/* ── Sprechen (tabbed chat) ── */
.exam-sprechen-tabs { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.exam-sp-tab {
  padding: .4rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  cursor: pointer;
  font-size: .88rem;
  transition: border-color .15s, background .15s;
}
.exam-sp-tab:hover { border-color: var(--brand); }
.exam-sp-tab.active { border-color: var(--brand); background: var(--brand); color: #fff; font-weight: 600; }
.exam-sp-card {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
}
.exam-sp-desc { font-size: .9rem; margin-bottom: .5rem; line-height: 1.6; }
.exam-sp-opener { font-size: .88rem; color: var(--text-2); font-style: italic; }
.exam-sp-chat {
  min-height: 200px; max-height: 380px;
  overflow-y: auto;
  padding: .75rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: .75rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.exam-sp-msg { padding: .5rem .75rem; border-radius: 10px; font-size: .9rem; line-height: 1.6; max-width: 90%; }
.exam-sp-msg.examiner { background: #eef2ff; align-self: flex-start; }
.exam-sp-msg.user     { background: #d1fae5; align-self: flex-end; }
.exam-sp-role { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .25rem; color: var(--text-2); }
.exam-sp-input-row { display: flex; gap: .5rem; align-items: flex-end; }
.exam-sp-input-row textarea { flex: 1; resize: none; }

/* ── Review ── */
.exam-review-body { padding-bottom: 2rem; }
.exam-result-box {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: .85rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
}
.result-great { background: #d1fae5; color: #065f46; }
.result-ok    { background: #fef9c3; color: #78350f; }
.result-poor  { background: #fee2e2; color: #991b1b; }
.exam-result-score { font-size: 1.5rem; font-weight: 800; }
.exam-result-pct   { font-size: .9rem; }

.exam-review-questions { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; }
.exam-review-row {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .6rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
}
.exam-review-row.correct { border-left: 3px solid var(--success, #10b981); }
.exam-review-row.wrong   { border-left: 3px solid var(--danger, #ef4444); }
.exam-review-icon { font-size: 1rem; flex-shrink: 0; margin-top: .1rem; }
.exam-review-qnum { font-weight: 700; min-width: 2rem; color: var(--text-2); flex-shrink: 0; }
.exam-review-detail { flex: 1; }
.exam-review-stem { margin-bottom: .15rem; }
.exam-review-context { font-style: italic; color: var(--text-2); font-size: .88rem; margin-bottom: .15rem; }
.exam-review-opts { font-size: .82rem; margin-bottom: .15rem; }
.text-success { color: var(--success, #10b981); }
.text-danger  { color: var(--danger, #ef4444); }

/* review transcript */
.exam-transcript { margin-top: 1.25rem; }
.exam-transcript-label { font-weight: 600; margin-bottom: .6rem; font-size: .88rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.exam-review-texts {
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: .93rem; line-height: 1.9;
}

/* Schreiben review */
.exam-schreiben-review { padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.exam-schreiben-review h4 { margin: 0 0 .75rem; }
.exam-criteria-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: .5rem 1rem; align-items: center;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.exam-criteria-row:last-of-type { border-bottom: none; }
.exam-criteria-name { }
.exam-criteria-grade { font-weight: 700; text-align: center; padding: .15rem .45rem; border-radius: 5px; font-size: .82rem; }
.exam-criteria-pts { text-align: right; color: var(--text-2); min-width: 3rem; }
.grade-a { background: #d1fae5; color: #065f46; }
.grade-b { background: #dbeafe; color: #1e40af; }
.grade-c { background: #fef9c3; color: #78350f; }
.grade-d { background: #fee2e2; color: #991b1b; }

/* Sprechen review */
.exam-sp-review { padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }

/* ── Confirm modal ── */
.exam-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.exam-modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.5rem 1.75rem;
  width: min(400px, 90vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.exam-modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; }
.exam-modal-msg   { font-size: .9rem; color: var(--text-2); margin-bottom: 1.25rem; line-height: 1.5; }
.exam-modal-btns  { display: flex; gap: .75rem; justify-content: flex-end; }
.exam-modal-btns .btn-primary { background: var(--danger, #ef4444); border-color: var(--danger, #ef4444); }

/* ═══════════════════════════════════════════════════════════════════════════
   Progress / B1 Preparedness Dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hero card ── */
.pg-hero {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.pg-hero-gauges {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

/* ── Circular gauge ── */
.pg-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  min-width: 90px;
}

.pg-gauge {
  --deg: 0deg;
  --color: var(--brand);
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: conic-gradient(var(--color) var(--deg), var(--border) var(--deg));
  display: flex;
  align-items: center;
  justify-content: center;
}

.pg-gauge-inner {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pg-gauge-val {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}

.pg-gauge-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.pg-gauge-sub {
  font-size: .7rem;
  color: var(--text-2);
  text-align: center;
}

/* ── Hero progress bar ── */
.pg-hero-bar-wrap {
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: .6rem;
}

.pg-hero-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width .5s ease;
}

.pg-hero-note {
  text-align: center;
  font-size: .9rem;
  font-weight: 600;
}

/* ── Detail grid ── */
.pg-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.pg-detail-card {
  padding: 1.1rem 1.25rem;
}

.pg-detail-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}

/* ── Stat rows ── */
.pg-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .88rem;
  color: var(--text-2);
  padding: .22rem 0;
}

.pg-stat-row strong {
  color: var(--text);
  font-weight: 600;
}

.pg-section-sub {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-2);
  margin: .75rem 0 .4rem;
}

/* ── Exercise/topic rows ── */
.pg-row {
  display: grid;
  grid-template-columns: 1fr 80px 36px 48px;
  align-items: center;
  gap: .4rem;
  padding: .28rem 0;
  font-size: .83rem;
}

.pg-row.clickable-row {
  cursor: pointer;
  border-radius: 6px;
  padding-left: .3rem;
  padding-right: .3rem;
}

.pg-row.clickable-row:hover {
  background: var(--bg);
}

.pg-row-label {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pg-row-pct {
  font-size: .78rem;
  font-weight: 600;
  text-align: right;
}

.pg-row-sub {
  font-size: .72rem;
  color: var(--text-2);
  text-align: right;
}

/* ── Mini bar ── */
.pg-mini-bar-wrap {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.pg-mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}

/* ── Topic list scrollable ── */
.pg-topic-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: .25rem;
}

.pg-topic-list::-webkit-scrollbar { width: 4px; }
.pg-topic-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Per-exercise attempt badge ── */
.ex-attempt-badge {
  font-size: .72rem;
  font-weight: 600;
  margin-left: auto;
  padding: .15rem .45rem;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Floating grammar chat widget
   ═══════════════════════════════════════════════════════════════════════════ */

.gr-float-chat {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .6rem;
  pointer-events: none; /* children opt-in */
}

/* ── Trigger button ── */
.gr-float-btn {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1rem .6rem .8rem;
  border-radius: 99px;
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  transition: background .15s, transform .15s;
}
.gr-float-btn:hover { background: var(--brand-dark, #4338ca); transform: translateY(-1px); }
.gr-float-btn.open  { background: var(--text-2); }

/* ── Chat panel ── */
.gr-float-panel {
  pointer-events: all;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 3rem));
  height: min(480px, calc(100vh - 8rem));
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  overflow: hidden;
  animation: floatIn .18s ease;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ── Panel header ── */
.gr-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1rem;
  background: var(--brand);
  color: #fff;
  flex-shrink: 0;
}
.gr-float-title {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.gr-float-title em { font-style: normal; opacity: .85; }

.gr-float-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: .15rem .35rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.gr-float-close:hover { color: #fff; background: rgba(255,255,255,.15); }

/* ── Messages area ── */
.gr-float-messages {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.gr-float-messages::-webkit-scrollbar { width: 4px; }
.gr-float-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.gr-float-msg {
  max-width: 88%;
  padding: .45rem .75rem;
  border-radius: 12px;
  font-size: .85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.gr-float-msg--assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.gr-float-msg--user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 3px;
}

/* ── Input row ── */
.gr-float-input-wrap {
  display: flex;
  gap: .4rem;
  padding: .6rem .75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.gr-float-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .42rem .75rem;
  font-size: .85rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.gr-float-input:focus { border-color: var(--brand); }

.gr-float-send {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.gr-float-send:hover { background: var(--brand-dark, #4338ca); }
.gr-float-send:disabled { opacity: .5; cursor: default; }

/* ═══════════════════════════════════════════════════════════════════════════
   Daily Practice modal
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Page header row ── */
.pg-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.pg-practice-btn {
  white-space: nowrap;
}

/* ── Overlay backdrop ── */
.dp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity .18s ease;
}
.dp-overlay.dp-visible  { opacity: 1; }
.dp-overlay.dp-closing  { opacity: 0; }

/* ── Modal box ── */
.dp-modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(640px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 16px 64px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(.97);
  transition: transform .18s ease;
}
.dp-overlay.dp-visible .dp-modal {
  transform: translateY(0) scale(1);
}

/* ── Header ── */
.dp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.dp-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.dp-subtitle {
  font-size: .82rem;
  color: var(--text-2);
  margin-top: .2rem;
}
.dp-close {
  background: none;
  border: none;
  font-size: 1.05rem;
  color: var(--text-2);
  cursor: pointer;
  padding: .15rem .4rem;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
}
.dp-close:hover { background: var(--bg); color: var(--text); }

/* ── Tiles grid ── */
.dp-tiles {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1rem 1.25rem;
}

/* ── Individual tile ── */
.dp-tile {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  transition: border-color .14s, box-shadow .14s, transform .1s;
  width: 100%;
}
.dp-tile:hover {
  box-shadow: 0 4px 14px rgba(99,102,241,.12);
  transform: translateY(-2px);
}

.dp-tile--high   { border-left: 4px solid var(--danger,#ef4444); }
.dp-tile--medium { border-left: 4px solid #f59e0b; }
.dp-tile--low    { border-left: 4px solid var(--success,#10b981); }

.dp-tile--high:hover   { border-color: var(--danger,#ef4444); }
.dp-tile--medium:hover { border-color: #f59e0b; }
.dp-tile--low:hover    { border-color: var(--success,#10b981); }

.dp-tile-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 2.2rem;
  text-align: center;
}

.dp-tile-body {
  flex: 1;
  min-width: 0;
}
.dp-tile-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin-bottom: .18rem;
}
.dp-tile-primary {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-tile-secondary {
  font-size: .78rem;
  color: var(--text-2);
  margin-top: .12rem;
}

.dp-tile-priority {
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  opacity: .6;
}
.dp-tile:hover .dp-tile-priority { opacity: 1; }

/* Done state */
.dp-tile--done {
  opacity: .52;
}
.dp-tile--done .dp-tile-primary {
  text-decoration: line-through;
  text-decoration-color: var(--text-2);
}

/* Done toggle button */
.dp-done-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: .82rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color .14s, background .14s, color .14s;
  padding: 0;
  line-height: 1;
}
.dp-done-btn:hover {
  border-color: var(--success, #10b981);
  color: var(--success, #10b981);
}
.dp-done-btn--done {
  background: var(--success, #10b981);
  border-color: var(--success, #10b981);
  color: #fff;
}

/* ── Footer ── */
.dp-footer {
  padding: .75rem 1.25rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Profile page
   ═══════════════════════════════════════════════════════════════════════════ */

/* Sidebar user block — make avatar+name clickable */
.sidebar-user-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  padding: .2rem .35rem;
  transition: background .14s;
}
.sidebar-user-link:hover { background: rgba(255,255,255,.08); }

/* ── Hero ── */
.pf-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.pf-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  transition: background .2s;
  user-select: none;
}

.pf-username {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.pf-joined {
  font-size: .82rem;
  color: var(--text-2);
  margin-top: .18rem;
}
.pf-visibility-pill {
  display: inline-block;
  margin-top: .5rem;
  font-size: .75rem;
  font-weight: 600;
  padding: .22rem .65rem;
  border-radius: 99px;
  border: 1px solid var(--border);
}
.pf-visibility-pill.public  { color: var(--success,#10b981); border-color: var(--success,#10b981); }
.pf-visibility-pill.private { color: var(--text-2); }

/* ── Sections ── */
.pf-section {
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.pf-section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .75rem;
}
.pf-section-hint {
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-2);
}

/* ── Color swatches ── */
.pf-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.pf-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.pf-swatch:hover  { transform: scale(1.15); }
.pf-swatch.active { border-color: var(--text); transform: scale(1.1); }

/* ── Emoji picker ── */
.pf-emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .6rem;
}
.pf-emoji-btn {
  width: 38px;
  height: 38px;
  font-size: 1.25rem;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .12s, transform .1s;
}
.pf-emoji-btn:hover  { border-color: var(--border); transform: scale(1.1); }
.pf-emoji-btn.active { border-color: var(--brand); background: var(--surface); }

.pf-clear-emoji {
  margin-top: .35rem;
}

/* ── Visibility toggle ── */
.pf-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}
.pf-toggle-label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.pf-toggle-desc {
  font-size: .8rem;
  color: var(--text-2);
  font-weight: 400;
}

.pf-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--border);
  position: relative;
  transition: background .18s;
  cursor: pointer;
  outline: none;
}
.pf-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.pf-toggle.on { background: var(--brand); }
.pf-toggle.on::after { transform: translateX(20px); }
.pf-toggle:focus-visible { box-shadow: 0 0 0 3px rgba(79,70,229,.35); }

/* ── Save row ── */
.pf-save-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.pf-save-status {
  font-size: .85rem;
  font-weight: 600;
}

/* ── Danger zone ── */
.pf-danger-zone {
  border: 1.5px solid var(--danger, #ef4444);
}
.pf-danger-title { color: var(--danger,#ef4444); }
.pf-danger-desc {
  font-size: .85rem;
  color: var(--text-2);
  margin-bottom: 1rem;
  line-height: 1.55;
}
.pf-delete-btn {
  background: var(--danger,#ef4444);
  color: #fff;
  border: none;
  padding: .5rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: .88rem;
  transition: opacity .12s;
}
.pf-delete-btn:hover    { opacity: .85; }
.pf-delete-btn:disabled { opacity: .5; cursor: default; }

/* ═══════════════════════════════════════════════════════════════════════════
   Friends page
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tabs ── */
.fr-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}
.fr-tab {
  background: none;
  border: none;
  padding: .55rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 6px 6px 0 0;
  transition: color .14s, border-color .14s;
}
.fr-tab:hover { color: var(--text); }
.fr-tab.active { color: var(--brand); border-color: var(--brand); }

/* ── Shared avatar ── */
.fr-avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}

/* ── Empty state ── */
.fr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 3rem 1rem;
  text-align: center;
}
.fr-empty--inline { padding: 1.5rem 1rem; }
.fr-empty-icon { font-size: 2.5rem; }
.fr-empty-text { font-size: 1rem; font-weight: 600; color: var(--text); }
.fr-empty-sub  { font-size: .85rem; color: var(--text-2); }

/* ── Friend cards (accepted) ── */
.fr-friend-list {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.fr-friend-card {
  padding: 1rem 1.25rem;
}
.fr-card-top {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: .85rem;
}
.fr-card-info { flex: 1; min-width: 0; }
.fr-card-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.fr-card-prep {
  font-size: .82rem;
  margin-top: .15rem;
}
.fr-card-meta {
  font-size: .75rem;
  color: var(--text-2);
  margin-top: .5rem;
}

.fr-remove-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: .9rem;
  padding: .25rem .4rem;
  border-radius: 6px;
  opacity: .6;
  transition: opacity .12s, background .12s;
  flex-shrink: 0;
}
.fr-remove-btn:hover { opacity: 1; background: var(--bg); }

/* ── Progress bars inside friend card ── */
.fr-progress-bars {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.fr-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 36px;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  color: var(--text-2);
}
.fr-mini-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.fr-mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}
.fr-bar-pct {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* ── Browse / search ── */
.fr-browse-wrap { display: flex; flex-direction: column; gap: 1rem; }
.fr-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: .55rem .9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.fr-search-input:focus { border-color: var(--brand); }

/* ── User grid (browse + requests) ── */
.fr-user-grid {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.fr-user-card {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1.1rem;
}
.fr-user-card-info { flex: 1; min-width: 0; }
.fr-user-card-action { flex-shrink: 0; }

.fr-req-actions { display: flex; gap: .4rem; }

/* ── Status badges ── */
.fr-badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .22rem .65rem;
  border-radius: 99px;
  white-space: nowrap;
}
.fr-badge--accepted { color: var(--success,#10b981); background: rgba(16,185,129,.1); }
.fr-badge--pending  { color: var(--text-2); background: var(--bg); border: 1px solid var(--border); }

/* ── Nickname in friend/user cards ── */
.fr-card-nick {
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-2);
}

/* ── Profile nickname field ── */
.pf-nickname {
  font-size: .85rem;
  color: var(--text-2);
  margin-top: .1rem;
}
.pf-nickname-row {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-bottom: .4rem;
}
.pf-nick-at {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}
.pf-nick-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .42rem .65rem;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.pf-nick-input:focus { border-color: var(--brand); }
.pf-nick-hint {
  font-size: .75rem;
  color: var(--text-2);
}

/* ── Login page: OAuth buttons ── */
.login-oauth-hint {
  color: var(--text-2);
  font-size: .88rem;
  margin-bottom: 1.25rem;
  text-align: center;
}
.login-oauth-btn-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: .75rem;
}

/* ── Login user cards: nickname sub-label ── */
.u-nick {
  font-size: .72rem;
  color: var(--text-2);
}

/* ── Nickname setup section on login page ── */
.nickname-setup {
  text-align: center;
}
.nickname-setup .new-user-form {
  margin-top: 1rem;
}

/* ── Admin dashboard ─────────────────────────────────────────────────────────── */
.adm-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.adm-summary-card { text-align: center; }
.adm-card-title   { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: .5rem; }
.adm-stat-big     { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.adm-stat-sub     { font-size: .75rem; color: var(--text-2); margin-bottom: .75rem; }
.adm-stat-row     { display: flex; justify-content: space-between; font-size: .82rem; padding: .15rem 0; border-top: 1px solid var(--border); }

.adm-module-row   { display: grid; grid-template-columns: 12px 120px 1fr 40px 90px 70px; align-items: center; gap: .75rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.adm-module-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.adm-module-name  { font-weight: 500; }
.adm-module-bar-wrap { background: var(--border); border-radius: 99px; height: 6px; }
.adm-module-bar-fill { height: 6px; border-radius: 99px; transition: width .4s; }
.adm-module-pct   { text-align: right; color: var(--text-2); font-size: .8rem; }
.adm-module-tokens{ text-align: right; font-weight: 600; }
.adm-module-reqs  { text-align: right; color: var(--text-2); font-size: .78rem; }

.adm-table        { width: 100%; border-collapse: collapse; font-size: .84rem; }
.adm-table th     { text-align: left; padding: .5rem .75rem; background: var(--bg); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); border-bottom: 2px solid var(--border); }
.adm-table td     { padding: .45rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.adm-table tr:hover td { background: var(--bg); }
.adm-model-cell   { font-family: monospace; font-size: .78rem; color: var(--text-2); }
.adm-modules-cell { font-size: .78rem; color: var(--text-2); }
.adm-table--detail .adm-module-dot { display: inline-block; margin-right: .35rem; vertical-align: middle; }

/* ── Selection-save popup ────────────────────────────────────────────────────── */
.sel-popup {
  position: fixed;
  z-index: 9999;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  box-shadow: 0 8px 28px rgba(99,102,241,.18);
  padding: .65rem .85rem;
  min-width: 200px;
  max-width: 260px;
  font-size: .85rem;
  pointer-events: auto;
}
.sel-popup-phrase {
  font-weight: 600;
  color: var(--text-1, #1e1b4b);
  margin-bottom: .35rem;
  word-break: break-word;
}
.sel-popup-loading {
  color: var(--text-2);
  font-size: .8rem;
}
.sel-popup-translation {
  color: var(--brand, #6366f1);
  font-size: .88rem;
  margin-bottom: .5rem;
  word-break: break-word;
}
.sel-popup-save {
  width: 100%;
  justify-content: center;
}

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .75rem 1rem;
  border-radius: 10px;
  font-size: .875rem;
  line-height: 1.4;
  max-width: 340px;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  animation: toast-in .2s ease;
  cursor: pointer;
}
.toast.toast--error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.toast.toast--warn    { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.toast.toast--info    { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
.toast.toast--success { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }
.toast-body { flex: 1; }
.toast-title { font-weight: 700; margin-bottom: .1rem; }
.toast-msg   { opacity: .85; }
.toast.toast--out { animation: toast-out .2s ease forwards; }
@keyframes toast-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform:translateY(4px); } }
