/* =====================================================================
   Dictionary + Language Training  --  Main stylesheet
   ===================================================================== */

:root {
  --brand:        #1e40af;
  --brand-dark:   #152a6b;
  --brand-light:  #dbeafe;
  --accent:       #0d9488;
  --accent-light: #ccfbf1;
  --danger:       #dc2626;
  --success:      #16a34a;
  --warning:      #d97706;
  --surface:      #ffffff;
  --bg:           #f1f5f9;
  --sidebar-w:    264px;
  --topbar-h:     64px;
  --radius:       14px;
  --shadow-sm:    0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.10);
  --shadow-md:    0 4px 16px rgba(15,23,42,.08);
  --shadow-lg:    0 12px 40px rgba(15,23,42,.14);
}

* { -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: #0f172a;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", system-ui, -apple-system, "Noto Sans Sinhala", "Iskoola Pota", sans-serif;
  font-size: 15px;
  overflow-x: hidden;
}

/* Sinhala friendly font stack for Sinhala glyphs */
.sinhala, [lang="si"], .sinhala-text {
  font-family: "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", "Segoe UI", sans-serif;
  line-height: 1.75;
}

/* ===================== TOP BAR ===================== */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  z-index: 1040;
  padding: 0 14px;
}
.topbar .d-flex { height: 100%; }
.topbar-title h1 { font-size: 1.05rem; font-weight: 700; margin: 0; line-height: 1.2; color: #0f172a; }
.topbar-title small  { color: #64748b; font-size: .78rem; }

.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; font-size: 1.05rem; flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(30,64,175,.28);
}
.brand-text strong { display: block; font-size: .98rem; color: #0f172a; line-height: 1.1; }
.brand-text small  { display: block; font-size: .68rem; color: #64748b; letter-spacing: .02em; }

.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; border-radius: 999px; padding: .3rem .75rem .3rem .3rem; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-light); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid #e2e8f0; z-index: 1030;
  overflow-y: auto;
}
.sidebar-brand { padding: 16px 18px 12px; border-bottom: 1px solid #eef2f7; }
.sidebar-nav { padding: 10px 10px 20px; }
.nav-group-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: #94a3b8; font-weight: 700; padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: .62rem .8rem; border-radius: 10px;
  color: #334155; text-decoration: none; font-weight: 500; font-size: .92rem;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-item i { width: 20px; text-align: center; font-size: .95rem; color: #64748b; transition: color .15s; }
.nav-item:hover { background: #f1f5f9; color: var(--brand); }
.nav-item:hover i { color: var(--brand); }
.nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.nav-item.active i { color: var(--brand); }
.nav-badge {
  margin-left: auto; background: var(--brand); color: #fff;
  font-size: .7rem; padding: .1rem .45rem; border-radius: 999px; font-weight: 700;
}
.sidebar-foot { padding: 12px 10px 16px; border-top: 1px solid #eef2f7; }

.app-offcanvas { width: 280px !important; }
.app-offcanvas .sidebar-nav { padding-top: 6px; }

/* ===================== LAYOUT ===================== */
.content {
  padding-top: calc(var(--topbar-h) + 18px);
  padding-bottom: 34px;
  min-height: 100vh;
}
.content.with-sidebar { margin-left: var(--sidebar-w); }
.page-wide .content .container-fluid { padding-left: 18px; padding-right: 18px; }
.page-actions { margin-top: 0; }

.app-footer { padding: 18px 0 26px; text-align: center; color: #64748b; font-size: .84rem; }
.content.with-sidebar + .app-footer, .app-footer { }

.btn-icon-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 1035;
  width: 44px; height: 44px; border-radius: 50%;
  box-shadow: var(--shadow-md); display: none;
}
.btn-icon-float.show { display: inline-flex; align-items: center; justify-content: center; }

/* ===================== CARDS ===================== */
.card {
  border: 1px solid #e6ebf2; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); background: var(--surface);
}
.card-header {
  background: #fff; border-bottom: 1px solid #eef2f7;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 600; padding: .85rem 1.1rem;
}
.card-body { padding: 1.1rem; }

.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.05rem 1.15rem; height: 100%; }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.stat-icon.bg-primary-soft { background: #dbeafe; color: #1d4ed8; }
.stat-icon.bg-success-soft { background: #dcfce7; color: #15803d; }
.stat-icon.bg-danger-soft  { background: #fee2e2; color: #b91c1c; }
.stat-icon.bg-warning-soft { background: #fef3c7; color: #b45309; }
.stat-icon.bg-info-soft    { background: #cffafe; color: #0e7490; }
.stat-icon.bg-accent-soft  { background: #ccfbf1; color: #0f766e; }
.stat-label { font-size: .76rem; color: #64748b; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.15; color: #0f172a; }
.stat-hint { font-size: .76rem; color: #94a3b8; }

.section-title { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; color: #94a3b8; margin-bottom: .6rem; }

/* ===================== TABLES ===================== */
.table { margin-bottom: 0; }
.table > thead th {
  background: #f8fafc; color: #475569; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 700; border-bottom: 1px solid #e2e8f0; white-space: nowrap;
  padding: .7rem .75rem; position: sticky; top: 0; z-index: 2;
}
.table > tbody td { padding: .7rem .75rem; vertical-align: middle; border-color: #f1f5f9; }
.table tbody tr:hover { background: #f8fbff; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.word-en { font-weight: 700; font-size: .98rem; }
.word-si { color: #0f766e; font-weight: 600; font-size: .95rem; }
.table-actions { display: flex; gap: .3rem; justify-content: flex-end; }

.badge-difficulty { font-size: .68rem; padding: .3em .6em; border-radius: 999px; font-weight: 700; }
.badge-difficulty.Easy   { background: #dcfce7; color: #15803d; }
.badge-difficulty.Medium { background: #fef3c7; color: #b45309; }
.badge-difficulty.Hard   { background: #fee2e2; color: #b91c1c; }
.badge-status { font-size: .68rem; padding: .3em .6em; border-radius: 999px; font-weight: 700; }
.badge-status.Active   { background: #dcfce7; color: #15803d; }
.badge-status.Inactive { background: #e2e8f0; color: #475569; }

/* ===================== BUTTONS ===================== */
.btn { border-radius: 10px; font-weight: 600; font-size: .9rem; }
.btn-lg { border-radius: 12px; font-size: 1rem; padding: .7rem 1.2rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #0f766e; border-color: #0f766e; color: #fff; }
.btn-speak {
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-light); color: #0f766e; border: 0; font-size: .9rem;
  transition: transform .12s;
}
.btn-speak:hover { background: #99f6e4; color: #0f766e; }
.btn-speak:active { transform: scale(.9); }
.btn-speak.is-speaking { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(13,148,136,.45); } 50% { box-shadow: 0 0 0 8px rgba(13,148,136,0); } }

.form-control, .form-select { border-radius: 10px; border-color: #dbe2ea; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(30,64,175,.12); }
.form-label { font-weight: 600; font-size: .86rem; color: #334155; }
.form-hint { font-size: .78rem; color: #94a3b8; }

/* ===================== TRAINING / QUIZ ===================== */
.quiz-hud {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem; margin-bottom: 1rem;
}
.hud-pill {
  background: #fff; border: 1px solid #e6ebf2; border-radius: 12px;
  padding: .55rem .8rem; text-align: center; box-shadow: var(--shadow-sm);
}
.hud-pill .hud-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; color: #94a3b8; font-weight: 700; }
.hud-pill .hud-value { font-size: 1.15rem; font-weight: 800; color: #0f172a; }
.hud-pill .hud-value.ok  { color: var(--success); }
.hud-pill .hud-value.bad { color: var(--danger); }
.hud-pill .hud-value.acc { color: var(--brand); }
.hud-pill.timer { background: #0f172a; border-color: #0f172a; }
.hud-pill.timer .hud-label { color: #94a3b8; }
.hud-pill.timer .hud-value { color: #fff; font-variant-numeric: tabular-nums; letter-spacing: .05em; }
.hud-pill.timer.warn { background: #b91c1c; border-color: #b91c1c; animation: timerFlash 1s infinite; }
@keyframes timerFlash { 0%,100% { opacity: 1; } 50% { opacity: .72; } }

.progress { background: #e2e8f0; border-radius: 999px; }
.progress-bar { background: linear-gradient(90deg, var(--brand), var(--accent)); }
.quiz-progress { height: 9px; }

.quiz-question {
  text-align: center; padding: 1.6rem 1rem 1.1rem;
}
.quiz-direction {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--brand); background: var(--brand-light); border-radius: 999px;
  display: inline-block; padding: .3rem .8rem; margin-bottom: .8rem;
}
.quiz-word {
  font-size: clamp(1.7rem, 6vw, 3rem); font-weight: 800; line-height: 1.15;
  color: #0f172a; word-break: break-word; margin: .3rem 0 .6rem;
}
.quiz-word.sinhala-text { font-size: clamp(1.6rem, 5.5vw, 2.7rem); }
.quiz-prompt { color: #64748b; font-size: .95rem; margin-bottom: .4rem; }
.quiz-speak { margin-top: .3rem; }

.answer-list { display: grid; gap: .7rem; grid-template-columns: repeat(2, 1fr); }
.answer-btn {
  position: relative; display: flex; align-items: center; gap: .7rem;
  border: 2px solid #e2e8f0; background: #fff; border-radius: var(--radius);
  padding: .95rem 1.05rem; text-align: left; font-size: 1.02rem; font-weight: 600;
  color: #0f172a; cursor: pointer; transition: all .15s; width: 100%;
  box-shadow: var(--shadow-sm); min-height: 58px;
}
.answer-btn:hover:not(:disabled) { border-color: var(--brand); background: #f8fbff; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.answer-btn:disabled { cursor: default; }
.answer-key {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px;
  background: #f1f5f9; color: #475569; display: inline-flex;
  align-items: center; justify-content: center; font-size: .78rem; font-weight: 800;
}
.answer-btn.pending { border-color: #94a3b8; background: #f1f5f9; opacity: .7; }
.answer-btn.correct { border-color: var(--success); background: #dcfce7; color: #14532d; }
.answer-btn.correct .answer-key { background: var(--success); color: #fff; }
.answer-btn.wrong { border-color: var(--danger); background: #fee2e2; color: #7f1d1d; }
.answer-btn.wrong .answer-key { background: var(--danger); color: #fff; }
.answer-btn.reveal { border-color: var(--success); border-style: dashed; }
.answer-btn.reveal .answer-key { background: var(--success); color: #fff; }

.feedback {
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-top: 1rem;
  display: flex; gap: .85rem; align-items: flex-start; border: 1px solid transparent;
}
.feedback i.feedback-icon { font-size: 1.4rem; line-height: 1; margin-top: .1rem; }
.feedback.ok  { background: #dcfce7; border-color: #86efac; color: #14532d; }
.feedback.bad { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.feedback.to  { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.feedback h6 { font-weight: 800; margin-bottom: .15rem; }
.feedback .score-delta { font-weight: 800; font-size: 1.05rem; }

.next-btn-wrap { margin-top: 1rem; text-align: right; }

/* ===================== PUZZLE ===================== */
.tile-bank { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; min-height: 62px; }
.letter-tile {
  width: 54px; height: 62px; border-radius: 12px; border: 2px solid #cbd5e1;
  background: #fff; font-size: 1.4rem; font-weight: 800; color: #0f172a;
  cursor: pointer; box-shadow: var(--shadow-sm); transition: all .12s;
  display: inline-flex; align-items: center; justify-content: center;
}
.letter-tile:hover:not(:disabled) { border-color: var(--brand); background: #f8fbff; }
.letter-tile.picked { opacity: .35; cursor: default; }
.tile-slot {
  min-height: 62px; display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center;
  border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: .7rem;
  background: #f8fafc;
}
.tile-slot .letter-tile { background: #fff; }

.gap-word { font-size: clamp(1.6rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: .1em; }
.gap-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.35em; height: 1.5em; margin: 0 .06em; border-bottom: 4px solid var(--brand);
  color: var(--brand); vertical-align: middle;
}
.gap-input {
  width: 1.4em; height: 1.5em; text-align: center; font-size: inherit; font-weight: 800;
  border: 0; border-bottom: 4px solid var(--brand); background: #fff; border-radius: 6px;
  text-transform: uppercase; color: var(--brand); padding: 0;
}
.gap-input:focus { outline: 3px solid rgba(30,64,175,.2); }

.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.match-item {
  display: block; width: 100%; text-align: left; border: 2px solid #e2e8f0; background: #fff;
  border-radius: 12px; padding: .8rem .95rem; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: all .15s; margin-bottom: .55rem; font-size: .98rem;
}
.match-item:hover:not(:disabled) { border-color: var(--brand); }
.match-item.active { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.match-item.done { opacity: .45; border-color: var(--success); background: #dcfce7; cursor: default; }
.match-item.miss { animation: shake .35s; border-color: var(--danger); background: #fee2e2; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.match-item .tick { float: right; color: var(--success); }
.match-status { text-align: center; font-weight: 700; color: #475569; min-height: 1.4rem; margin-bottom: .8rem; }

/* ===================== PUZZLE: added game modes ===================== */

/* typeword / listen: single free-text answer */
.pz-typebox { max-width: 26rem; margin: 0 auto; }
.pz-typebox .form-control { font-weight: 700; letter-spacing: .06em; }
.pz-listen { font-size: 2.4rem !important; width: 4.6rem; height: 4.6rem; border-radius: 50%; }

/* hangman: masked word + on-screen keyboard */
.hz-keys { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; max-width: 34rem; margin: 0 auto; }
.hz-keys .letter-tile { width: 2.5rem; padding: .5rem 0; text-align: center; }
.hz-keys .letter-tile.hit  { border-color: var(--success); background: #dcfce7; color: #14532d; opacity: 1; }
.hz-keys .letter-tile.miss { border-color: var(--danger); background: #fee2e2; color: #7f1d1d; opacity: .6; }

/* odd one out: word options in a list */
.word-option .sinhala-text { font-family: var(--font-sinhala); }

/* alpha / chain: the built-up order and the remaining pool */
.pz-order { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; align-items: center; min-height: 3.2rem; margin-bottom: 1rem; }
.pz-order:empty::after { content: "Tap a word below to start"; color: #94a3b8; font-size: .9rem; }
.pz-order-pool { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.pz-order-btn { min-width: 8.5rem; }
.pz-order-btn.picked { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.pz-order-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: .8rem; font-weight: 800; margin-right: .5rem;
}
.pz-link { font-weight: 800; color: #94a3b8; }
.pz-link.ok  { color: var(--success); }
.pz-link.bad { color: var(--danger); }

/* real or fake: two large verdict buttons */
.rf-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 30rem; margin: 1.5rem auto 0; }
.rf-btn { padding: 1.1rem; font-weight: 800; font-size: 1.1rem; }
.rf-real { border-color: var(--success); color: #14532d; }
.rf-real:hover:not(:disabled) { background: #dcfce7; }
.rf-fake { border-color: var(--danger); color: #7f1d1d; }
.rf-fake:hover:not(:disabled) { background: #fee2e2; }

/* category sort: two drop targets */
.pz-buckets { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.2rem; }
.pz-bucket { border: 2px dashed #cbd5e1; border-radius: 14px; padding: .8rem; background: #f8fafc; }
.pz-bucket-title { font-weight: 800; text-align: center; color: var(--brand); margin-bottom: .6rem; }
.pz-bucket-items { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.pz-bucket-add { width: 100%; }

@media (max-width: 576px) {
  .rf-buttons, .pz-buckets { grid-template-columns: 1fr; }
  .hz-keys .letter-tile { width: 2.1rem; }
}

/* ===================== LOGIN ===================== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 10% -10%, #1e40af33, transparent),
    radial-gradient(800px 400px at 100% 110%, #0d948833, transparent),
    linear-gradient(160deg, #0f172a 0%, #1e3a8a 55%, #0f766a 100%);
}
.auth-card { width: 100%; max-width: 960px; border: 0; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-lg); }
.auth-side {
  background: linear-gradient(160deg, var(--brand-dark), var(--brand) 55%, var(--accent));
  color: #fff; padding: 2.4rem 2rem; position: relative; overflow: hidden;
}
.auth-side::after {
  content: ""; position: absolute; right: -60px; bottom: -60px; width: 240px; height: 240px;
  border-radius: 50%; background: rgba(255,255,255,.09);
}
.auth-side h2 { font-weight: 800; }
.auth-side .feature { display: flex; gap: .7rem; align-items: flex-start; margin-bottom: .9rem; font-size: .9rem; }
.auth-side .feature i { margin-top: .2rem; color: #5eead4; }
.auth-form { padding: 2.2rem 2rem; background: #fff; }
.demo-creds { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 10px; padding: .7rem .85rem; font-size: .82rem; }

/* ===================== MISC ===================== */
.empty-state { text-align: center; padding: 3rem 1rem; color: #94a3b8; }
.empty-state i { font-size: 3rem; margin-bottom: .8rem; display: block; opacity: .5; }
.empty-state h5 { color: #475569; font-weight: 700; }

.chip {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid #dbe2ea;
  background: #fff; border-radius: 999px; padding: .4rem .85rem; font-size: .85rem;
  font-weight: 600; color: #475569; cursor: pointer; transition: all .14s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; }

.result-hero {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand) 60%, var(--accent));
  color: #fff; border-radius: 18px; padding: 1.8rem 1.4rem; text-align: center;
}
.result-hero .score-big { font-size: 3.2rem; font-weight: 900; line-height: 1; }
.result-hero .label { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; opacity: .85; font-weight: 700; }

.review-table { font-size: .9rem; }
.review-table .q-si { color: #0f766e; font-weight: 600; }
.badge-res { font-weight: 700; font-size: .7rem; padding: .3em .55em; border-radius: 999px; }
.badge-res.Correct { background: #dcfce7; color: #15803d; }
.badge-res.Wrong { background: #fee2e2; color: #b91c1c; }
.badge-res.Timeout { background: #fef3c7; color: #b45309; }
.badge-res.Skipped { background: #e2e8f0; color: #475569; }

.difficulty-bar { height: 7px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.difficulty-bar > span { display: block; height: 100%; border-radius: 999px; }

.spinner-wrap { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.toast-area-item { font-size: .9rem; }
.modal-header { border-bottom: 1px solid #eef2f7; }
.nav-pills .nav-link { color: #475569; font-weight: 600; }
.nav-pills .nav-link.active { background: var(--brand); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); }
.modal-content { border-radius: var(--radius); border: 0; box-shadow: var(--shadow-lg); }
.list-group-item { border-color: #f1f5f9; }
.sinhala { word-break: break-word; }
.lead-sinhala { font-size: 2.6rem; line-height: 1.6; color: #0f766e; font-weight: 700; }
.text-sinhala { font-family: "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 991.98px) {
  .content.with-sidebar { margin-left: 0; }
  .content { padding-top: calc(var(--topbar-h) + 14px); }
  .topbar { padding: 0 10px; }
  .auth-side { display: none; }
  .auth-form { padding: 1.8rem 1.3rem; }
  .answer-list { grid-template-columns: 1fr; }
  .answer-btn { font-size: 1.12rem; min-height: 64px; }
  .match-cols { grid-template-columns: 1fr; }
  .letter-tile { width: 50px; height: 58px; font-size: 1.3rem; }
  .app-footer { text-align: center; }
}
@media (max-width: 575.98px) {
  body { font-size: 14.5px; }
  .stat-card { padding: .85rem .9rem; gap: .75rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.1rem; }
  .stat-value { font-size: 1.3rem; }
  .quiz-question { padding: 1.2rem .5rem .8rem; }
  .card-body { padding: .9rem; }
  .result-hero .score-big { font-size: 2.6rem; }
  .hud-pill .hud-value { font-size: 1.05rem; }
}

@media print {
  .sidebar, .topbar, .app-footer, .page-actions, .btn, .btn-icon-float { display: none !important; }
  .content { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ==========================================================================
 |  Printable question paper (mcq_print.php)
 |  Screen layout first, then a clean sheet of paper for the printer.
 * ========================================================================== */

.paper-bar {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem;
  padding: .75rem 1rem; margin-bottom: 1.25rem;
}

.paper-sheet {
  background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem;
  padding: 2rem 2.25rem; max-width: 900px;
}

.paper-head { border-bottom: 2px solid #0f172a; padding-bottom: .75rem; margin-bottom: 1rem; }
.paper-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; color: #0f172a; }
.paper-meta { font-size: .85rem; color: #64748b; }

.paper-ident { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }
.paper-ident > div { display: flex; align-items: baseline; gap: .5rem; flex: 1 1 180px; }
.paper-ident span:first-child { font-size: .8rem; color: #475569; font-weight: 600; }
.paper-ident .fill { flex: 1; border-bottom: 1px solid #94a3b8; min-width: 80px; }

.paper-instructions {
  font-size: .9rem; color: #334155;
  background: #f8fafc; border-left: 3px solid var(--brand, #1e3a8a);
  padding: .6rem .8rem; margin-bottom: 1.25rem;
}

/* ---- questions ---- */
.paper-questions { list-style: none; margin: 0; padding: 0; counter-reset: q; }
.paper-questions > li {
  counter-increment: q;
  padding: .55rem 0; border-bottom: 1px dotted #cbd5e1;
  break-inside: avoid; page-break-inside: avoid;
}
.paper-questions > li > .q-text { font-size: 1.02rem; font-weight: 600; color: #0f172a; }
.paper-questions > li > .q-text::before { content: counter(q) ". "; color: #64748b; font-weight: 700; }
.paper-questions .sinhala { font-family: "Noto Sans Sinhala", "Iskoola Pota", sans-serif; }

.q-options {
  list-style: none; margin: .4rem 0 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: .3rem 1.5rem;
}
.q-options li { display: flex; align-items: baseline; gap: .45rem; }
.opt-letter { font-weight: 700; color: #475569; font-size: .85rem; min-width: 1ch; }
.opt-bubble {
  width: 11px; height: 11px; border: 1.5px solid #64748b; border-radius: 50%;
  flex: 0 0 auto; align-self: center; display: inline-block;
}
.opt-text { font-size: .93rem; color: #1e293b; }
.q-text, .opt-text { position: relative; }
.speakable { cursor: pointer; }
.speakable:hover { text-decoration: underline dotted; }
.screen-only { display: inline; }

/* ---- answer sheet ---- */
.answer-sheet { margin-top: 2rem; break-inside: avoid; page-break-inside: avoid; }
.answer-sheet h2 {
  font-size: 1rem; font-weight: 700; color: #0f172a;
  border-bottom: 1px solid #cbd5e1; padding-bottom: .3rem; margin-bottom: .8rem;
}
.sheet-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: .5rem; }
.sheet-cell { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.sheet-no { font-size: .8rem; font-weight: 700; color: #475569; }
.sheet-circle { width: 20px; height: 20px; border: 1.5px solid #334155; border-radius: 50%; }

/* ---- answer key ---- */
.paper-key-sheet { margin-top: 1.5rem; }
.paper-key-sheet > summary {
  cursor: pointer; font-weight: 600; color: #0f172a;
  background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem;
  padding: .7rem 1rem; list-style: none;
}
.paper-key-sheet > summary::-webkit-details-marker { display: none; }
.paper-key-sheet > summary::before { content: "\f077"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: .5rem; font-size: .8rem; color: #64748b; }
.paper-key-sheet:not([open]) > summary::before { content: "\f078"; }
.paper-key-sheet .key-inner { margin-top: .75rem; }

.key-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.key-table th, .key-table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid #e2e8f0; }
.key-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; }
.key-table .num { width: 40px; color: #64748b; }
.key-letter { font-weight: 700; color: #15803d; width: 60px; }
.key-note { margin-top: 1rem; font-size: .85rem; color: #475569; }
.paper-foot { margin-top: 2rem; padding-top: .5rem; border-top: 1px solid #e2e8f0; font-size: .75rem; color: #94a3b8; text-align: center; }

@media (max-width: 700px) {
  .paper-sheet { padding: 1.25rem 1rem; }
  .q-options { grid-template-columns: 1fr; }
  .sheet-grid { grid-template-columns: repeat(5, 1fr); }
}

@media print {
  @page { size: A4; margin: 14mm 12mm; }

  body { background: #fff !important; font-size: 11.5pt; }

  .no-print, .screen-only, .paper-bar, .sidebar, .topbar, .app-footer,
  .page-actions, .alert, .btn { display: none !important; }

  .content, .content.with-sidebar { margin: 0 !important; padding: 0 !important; }
  .paper-sheet {
    border: 0; border-radius: 0; padding: 0; max-width: none; background: #fff;
  }

  /* The key always prints on its own sheet, and its <details> is forced
     open so it can never be an empty page. */
  .paper-key-sheet { margin: 0; }
  .paper-key-sheet > summary { display: none !important; }
  .paper-key-sheet .key-inner { margin: 0; break-before: page; page-break-before: always; }

  /* "Print Question Paper" / "Print Answer Key" print one section only. */
  body.printing-paper .paper-key-sheet { display: none !important; }
  body.printing-key .paper-questions-sheet { display: none !important; }
  body.printing-key .paper-key-sheet .key-inner { break-before: auto; page-break-before: auto; }

  /* Never split a question or the answer sheet across pages */
  .paper-questions > li, .answer-sheet, .key-table tr { break-inside: avoid; page-break-inside: avoid; }

  /* Keep the question word with its options */
  .paper-questions > li > .q-text { break-after: avoid; page-break-after: avoid; }

  .paper-head { border-bottom: 1.5pt solid #0f172a; }
  .paper-instructions { background: #f1f5f9; }
  .q-options { gap: .25rem 1rem; }
  .opt-bubble, .sheet-circle { border-color: #000; }
  .sinhala { font-family: "Noto Sans Sinhala", "Iskoola Pota", sans-serif; }

  a[href]::after { content: ""; }
}

@media print {
  .sidebar, .topbar, .app-footer, .page-actions, .btn, .btn-icon-float { display: none !important; }
  .content { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
