/* =============================================
   Amiri Arabic Font — Hosted Locally
   (No dependency on Google Fonts for Arabic)
   ============================================= */

/* Arabic subset */
@font-face {
    font-family: 'Amiri';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/amiri-regular-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891,
                   U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011,
                   U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* Latin subset */
@font-face {
    font-family: 'Amiri';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/amiri-regular-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
                   U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC,
                   U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Arabic Bold */
@font-face {
    font-family: 'Amiri';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/amiri-bold-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891,
                   U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011,
                   U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* Latin Bold */
@font-face {
    font-family: 'Amiri';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/amiri-bold-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
                   U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC,
                   U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =============================================
   app.css v2.1 — MengajiPro Mobile Web App
   Design: Islamic Minimal Dark + Gold
   Mobile-first, PWA-ready
============================================= */

:root {
    --bg-deep:     #0d1117;
    --bg-surface:  #161b22;
    --bg-card:     #1c2333;
    --bg-hover:    #21283a;
    --border:      #30363d;
    --border-soft: #21283a;

    --gold:        #c9a227;
    --gold-light:  #e0b84a;
    --gold-dim:    rgba(201,162,39,0.12);

    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --text-muted:     #484f58;

    --green:      #2ea043;
    --green-dim:  rgba(46,160,67,0.15);
    --red:        #da3633;
    --red-dim:    rgba(218,54,51,0.15);
    --blue:       #388bfd;
    --blue-dim:   rgba(56,139,253,0.15);
    --orange:     #e3b341;
    --orange-dim: rgba(227,179,65,0.15);
    --purple:     #8957e5;
    --purple-dim: rgba(137,87,229,0.15);
    --teal:       #39d353;
    --teal-dim:   rgba(57,211,83,0.12);

    --sidebar-w:    260px;
    --topbar-h:     56px;
    --bottom-nav-h: 64px;
    --radius:       8px;
    --radius-lg:    14px;
    --radius-xl:    20px;

    --font-body: 'IBM Plex Sans', sans-serif;
    --font-arab: 'Amiri', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --shadow:    0 1px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.5);

    --touch-min:   44px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top:    env(safe-area-inset-top, 0px);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }
img { max-width: 100%; }

/* =============================================
   SIDEBAR
============================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 99;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.28s;
}
.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-brand {
    padding: 1.1rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 1;
    flex-shrink: 0;
}

.brand-icon {
    width: 38px; height: 38px;
    background: var(--gold-dim);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    display: grid; place-items: center;
    font-size: 1.3rem;
    color: var(--gold);
    flex-shrink: 0;
}

.brand-text { flex: 1; min-width: 0; }
.brand-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); display: block; }
.brand-sub  { font-size: 0.7rem; color: var(--text-muted); display: block; }

/* Close btn: hidden on desktop, shown via media query on mobile */
.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    width: var(--touch-min);
    height: var(--touch-min);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    margin-left: auto;
    flex-shrink: 0;
}
.sidebar-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}

.user-avatar {
    width: 34px; height: 34px;
    background: var(--gold);
    color: var(--bg-deep);
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700; font-size: 0.9rem;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: 0.85rem; font-weight: 500; display: block;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 0.7rem; color: var(--text-muted); display: block; }

.sidebar-nav { list-style: none; padding: 0.5rem 0; flex: 1; overflow-y: auto; }
.sidebar-nav li { margin: 2px 0.5rem; }

.nav-link {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-height: var(--touch-min);
    transition: all 0.18s;
}
.nav-link:hover  { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--gold-dim); color: var(--gold); font-weight: 500; }
.nav-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.logout-btn {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    min-height: var(--touch-min);
    color: var(--text-muted);
    font-size: 0.85rem;
    border-radius: var(--radius);
    transition: all 0.18s;
}
.logout-btn:hover { background: var(--red-dim); color: var(--red); }

/* =============================================
   MAIN LAYOUT
============================================= */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: calc(100vw - var(--sidebar-w));
    overflow-x: hidden;
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    padding-top: var(--safe-top);
    position: sticky; top: 0; z-index: 90;
    flex-shrink: 0;
}

/* Hamburger: hidden on desktop, shown on mobile */
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    width: var(--touch-min);
    height: var(--touch-min);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.topbar-title {
    font-size: 0.95rem;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

.page-content {
    padding: 1.5rem;
    flex: 1;
    width: 100%;
}

/* Content max-width for readability on large screens */
.page-content > * { max-width: 1200px; }

/* =============================================
   BOTTOM NAVIGATION (Mobile only)
============================================= */
.bottom-nav {
    display: none; /* overridden in mobile media query */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: 95;
    align-items: stretch;
    justify-content: space-around;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 0.25rem;
    min-height: var(--touch-min);
    transition: color 0.18s;
    position: relative;
}
.bottom-nav-item::before {
    content: '';
    position: absolute;
    top: 0; left: 25%; right: 25%;
    height: 2px;
    background: var(--gold);
    border-radius: 0 0 2px 2px;
    transform: scaleX(0);
    transition: transform 0.18s;
}
.bottom-nav-item.active,
.bottom-nav-item:hover { color: var(--gold); }
.bottom-nav-item.active::before { transform: scaleX(1); }

.bnav-icon  { font-size: 1.2rem; line-height: 1; }
.bnav-label { font-size: 0.65rem; font-weight: 500; letter-spacing: 0.01em; }

/* =============================================
   PWA INSTALL BANNER
============================================= */
.pwa-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    padding: 0.6rem 1rem;
    box-shadow: var(--shadow-lg);
}
.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
}
.pwa-icon { font-size: 1.5rem; flex-shrink: 0; }
.pwa-text { flex: 1; }
.pwa-text strong { display: block; font-size: 0.85rem; }
.pwa-text small  { color: var(--text-secondary); font-size: 0.75rem; }
.btn-ghost { background: none; border: none; color: var(--text-muted); cursor: pointer;
             padding: 0.4rem; border-radius: var(--radius); font-size: 1rem; }

/* =============================================
   AUTH LAYOUT
============================================= */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-deep);
    padding: 1.5rem 1rem;
    padding-bottom: calc(1.5rem + var(--safe-bottom));
    width: 100%;
}

.auth-bg {
    position: fixed; inset: 0; z-index: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(201,162,39,0.06) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 80% 80%, rgba(56,139,253,0.05) 0%, transparent 70%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.auth-brand { text-align: center; }
.auth-brand-icon { font-size: 2.5rem; color: var(--gold); }
.auth-brand-name { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); display: block; }
.auth-brand-tagline { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.25rem; }

.auth-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-card-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; }
.auth-alt-link   { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--text-secondary); }
.auth-footer-note { font-family: var(--font-arab); color: var(--gold); font-size: 1.1rem; opacity: 0.6; }
.auth-demo-creds {
    margin-top: 1rem; padding: 0.75rem;
    background: var(--bg-surface); border-radius: var(--radius);
    color: var(--text-secondary); text-align: center;
    font-size: 0.78rem; border: 1px solid var(--border-soft);
}

/* Password toggle */
.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-right: 3rem; }
.btn-toggle-password {
    position: absolute; right: 0; top: 0; bottom: 0;
    width: 2.75rem;
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: color 0.18s;
}
.btn-toggle-password:hover { color: var(--text-primary); }

/* Password strength */
.password-strength { margin-top: 0.4rem; }
.pw-bar  { height: 4px; background: var(--bg-surface); border-radius: 2px; overflow: hidden; }
.pw-fill { height: 100%; transition: width 0.3s, background 0.3s; border-radius: 2px; }
.pw-weak .pw-fill        { background: var(--red); }
.pw-fair .pw-fill        { background: var(--orange); }
.pw-good .pw-fill        { background: var(--blue); }
.pw-strong .pw-fill      { background: var(--green); }
.pw-very-strong .pw-fill { background: var(--teal); }
.pw-label   { font-size: 0.7rem; color: var(--text-secondary); }
.form-hint  { font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 0.3rem; }
.mt-2       { margin-top: 0.75rem; }
.alert-link { color: var(--green); font-weight: 500; }
.alert-icon { margin-right: 0.35rem; }

/* =============================================
   COMPONENTS
============================================= */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.card-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-header h3 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 0.65rem 0.85rem;
    font-size: 16px; /* Prevent iOS zoom */
    font-family: var(--font-body);
    transition: border-color 0.18s, box-shadow 0.18s;
    -webkit-appearance: none;
    min-height: var(--touch-min);
}
.form-control:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,162,39,0.15);
}
select.form-control { cursor: pointer; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s;
    font-family: var(--font-body);
    text-decoration: none;
    min-height: var(--touch-min);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gold);
    color: var(--bg-deep);
    border-color: var(--gold);
}
.btn-primary:hover, .btn-primary:active { background: var(--gold-light); color: var(--bg-deep); }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

.btn-sm    { padding: 0.35rem 0.75rem; font-size: 0.78rem; min-height: 34px; }
.btn-lg    { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.auth-form .btn-primary { width: 100%; padding: 0.75rem; }

/* Alerts */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.alert-danger  { background: var(--red-dim);   border: 1px solid var(--red);   color: #ff7b7a; }
.alert-success { background: var(--green-dim);  border: 1px solid var(--green); color: #7ee787; }

/* =============================================
   STATS ROW
============================================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem;
    text-align: center;
    transition: border-color 0.18s, transform 0.18s;
}
.stat-card:hover { border-color: var(--gold); transform: translateY(-1px); }

.stat-icon  { font-size: 1.6rem; margin-bottom: 0.35rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--gold); line-height: 1; }
.stat-value small { font-size: 0.75rem; color: var(--text-secondary); }
.stat-label { font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* =============================================
   DASHBOARD
============================================= */
.dashboard-grid { display: flex; flex-direction: column; gap: 0; }

.quick-action-card {
    background: linear-gradient(135deg, #1c2a1a 0%, var(--bg-card) 100%);
    border: 1px solid rgba(201,162,39,0.3);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem;
    overflow: hidden;
    position: relative;
}
.qa-content h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
.qa-content p  { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1rem; }
.qa-deco { opacity: 0.07; position: absolute; right: 1.5rem; top: 50%; transform: translateY(-50%); }
.arabic-deco { font-family: var(--font-arab); font-size: 5rem; color: var(--gold); }

/* Session list */
.session-list { display: flex; flex-direction: column; gap: 0.4rem; }
.session-item {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s;
    min-height: var(--touch-min);
    color: var(--text-primary);
}
.session-item:hover { background: var(--bg-hover); border-color: var(--border); }

.session-surah { font-family: var(--font-arab); font-size: 1.1rem; display: block; }
.session-ayah  { font-size: 0.75rem; color: var(--text-secondary); }
.session-meta  { flex: 1; min-width: 0; }
.session-date  { font-size: 0.72rem; color: var(--text-muted); }

.score-ring {
    width: 50px; height: 50px; border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700; font-size: 0.82rem;
    border: 2px solid; flex-shrink: 0;
}
.score-ring.score-excellent { border-color: var(--green);  color: var(--green); }
.score-ring.score-good      { border-color: var(--blue);   color: var(--blue); }
.score-ring.score-fair      { border-color: var(--orange); color: var(--orange); }
.score-ring.score-poor      { border-color: var(--red);    color: var(--red); }

/* Fluency badges */
.fluency-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem; font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}
.badge-excellent { background: var(--green-dim);  color: #7ee787; }
.badge-good      { background: var(--blue-dim);   color: #79c0ff; }
.badge-fair      { background: var(--orange-dim); color: var(--orange); }
.badge-poor      { background: var(--red-dim);    color: #ff7b7a; }

/* Mistake bars */
.mistake-bars { display: flex; flex-direction: column; gap: 0.75rem; }
.mistake-bar-item { display: flex; align-items: center; gap: 0.75rem; }
.mistake-type  { width: 80px; font-size: 0.8rem; color: var(--text-secondary); text-transform: capitalize; }
.bar-wrap      { flex: 1; height: 8px; background: var(--bg-surface); border-radius: 4px; overflow: hidden; }
.bar-fill      { height: 100%; border-radius: 4px; background: var(--gold); transition: width 0.8s; }
.bar-mad       { background: var(--blue); }
.bar-ghunnah   { background: var(--purple); }
.bar-ikhfa     { background: var(--teal); }
.bar-qalqalah  { background: var(--orange); }
.bar-idgham    { background: var(--green); }
.bar-other     { background: var(--text-muted); }
.mistake-count { font-size: 0.75rem; color: var(--text-secondary); width: 30px; text-align: right; }

/* =============================================
   SEARCH FORM
============================================= */
.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}
.search-form .form-control {
    width: 160px;
    min-height: 36px;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
}

/* =============================================
   PRACTICE PAGE
============================================= */
.practice-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.25rem;
    align-items: start;
}

.ayah-display { margin-top: 1rem; }
.loading-ayah { color: var(--text-muted); font-style: italic; text-align: center; padding: 2rem; }

.ayah-block {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-soft);
}
.ayah-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.ayah-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    background: var(--gold-dim);
    border: 1px solid var(--gold);
    border-radius: 50%;
    font-size: 0.72rem; font-weight: 700;
    color: var(--gold); margin-bottom: 0.75rem;
}

.ayah-arabic {
    font-family: var(--font-arab);
    font-size: 1.7rem;
    line-height: 2.2;
    color: var(--text-primary);
    text-align: right;
}
.ayah-translation { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.5rem; line-height: 1.7; }

.selector-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.selector-row .form-group { flex: 1; min-width: 100px; }

.ref-audio-section { margin-top: 1rem; }
.ref-audio-label   { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 0.4rem; display: block; }
.ref-audio-player  { width: 100%; height: 40px; border-radius: var(--radius); }
.playback-player   { width: 100%; height: 40px; }

/* Recorder */
.recorder-panel { display: flex; flex-direction: column; gap: 1rem; }
.recorder-card .card-body { display: flex; flex-direction: column; gap: 1rem; align-items: center; }

.visualizer-wrap {
    width: 100%;
    background: var(--bg-surface);
    border-radius: var(--radius);
    overflow: hidden;
    height: 64px;
}
#audioVisualizer { width: 100%; height: 64px; }

.timer-display {
    font-size: 2.2rem; font-weight: 700;
    font-family: var(--font-mono);
    color: var(--gold); letter-spacing: 0.1em;
}

.recorder-controls { display: flex; gap: 0.75rem; justify-content: center; }

.btn-record, .btn-stop {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-lg); cursor: pointer;
    font-size: 0.95rem; font-weight: 600;
    border: none; transition: all 0.18s;
    font-family: var(--font-body);
    min-height: 50px;
    -webkit-tap-highlight-color: transparent;
}
.btn-record {
    background: var(--green); color: white;
    animation: pulse-green 2s infinite;
}
.btn-stop { background: var(--red); color: white; }

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46,160,67,0.4); }
    50%       { box-shadow: 0 0 0 10px rgba(46,160,67,0); }
}

.rec-icon { font-size: 1rem; }
.playback-section { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }

.transcript-section { width: 100%; }
.transcript-label { font-size: 0.78rem; color: var(--text-secondary); display: block; margin-bottom: 0.4rem; }
.transcript-box {
    min-height: 80px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.85rem;
}
.transcript-placeholder { color: var(--text-muted); font-style: italic; }
.transcript-text { font-family: var(--font-arab); font-size: 1.1rem; line-height: 2; text-align: right; }
.interim { color: var(--text-muted); }
.transcript-note { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.3rem; display: block; }
.transcript-note.info { color: #0369a1; background: #e0f2fe; padding: 8px 12px; border-radius: 8px; font-style: normal; border-left: 3px solid #0284c7; }

.btn-analyze {
    padding: 0.9rem;
    font-size: 1rem;
    background: var(--gold);
    color: var(--bg-deep);
    border: none; cursor: pointer;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-family: var(--font-body);
    transition: all 0.18s;
    width: 100%;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}
.btn-analyze:not(:disabled):hover  { background: var(--gold-light); transform: translateY(-1px); }
.btn-analyze:not(:disabled):active { transform: translateY(0); }
.btn-analyze:disabled { opacity: 0.4; cursor: not-allowed; }

/* Result Preview */
.result-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.result-score-big { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }

.score-circle {
    width: 90px; height: 90px;
    border-radius: 50%; border: 3px solid;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.score-circle.score-circle-excellent { border-color: var(--green); }
.score-circle.score-circle-good      { border-color: var(--blue); }
.score-circle.score-circle-fair      { border-color: var(--orange); }
.score-circle.score-circle-poor      { border-color: var(--red); }

#scoreValue { font-size: 1.6rem; font-weight: 800; }
.score-circle small { font-size: 0.75rem; }
.score-details  { flex: 1; }
.score-grade    { font-size: 0.9rem; font-weight: 600; }
.score-fluency  { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }

.preview-subtitle { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
                    margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }

.preview-mistake {
    display: flex; gap: 0.5rem; align-items: flex-start;
    padding: 0.5rem 0.6rem; border-radius: var(--radius);
    margin-bottom: 0.35rem; font-size: 0.8rem;
    border-left: 3px solid transparent;
}
.severity-critical { background: var(--red-dim);    border-left-color: var(--red); }
.severity-major    { background: var(--orange-dim); border-left-color: var(--orange); }
.severity-minor    { background: var(--blue-dim);   border-left-color: var(--blue); }

.pm-num  { font-weight: 700; color: var(--text-muted); min-width: 18px; }
.pm-type { font-weight: 600; color: var(--text-secondary); min-width: 70px; text-transform: capitalize; }
.pm-desc { color: var(--text-primary); flex: 1; }

.no-mistakes  { padding: 0.75rem; background: var(--green-dim); border-radius: var(--radius); color: #7ee787; font-size: 0.85rem; }
.more-mistakes { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 0.25rem; }

.preview-tip {
    padding: 0.5rem 0.75rem;
    background: var(--gold-dim);
    border-radius: var(--radius);
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
}

/* =============================================
   RESULT PAGE
============================================= */
.result-page { max-width: 900px; }
.result-header { margin-bottom: 1.25rem; }

.res-surah-ar   { font-family: var(--font-arab); font-size: 1.8rem; display: block; text-align: right; }
.res-surah-name { font-size: 1rem; font-weight: 600; display: block; margin: 0.25rem 0; }
.res-ayah       { font-size: 0.82rem; color: var(--text-secondary); }
.result-surah-info { margin-bottom: 1.25rem; }

.result-score-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }

.result-circle {
    width: 110px; height: 110px;
    border-radius: 50%; border: 4px solid;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.result-circle-excellent { border-color: var(--green); }
.result-circle-good      { border-color: var(--blue); }
.result-circle-fair      { border-color: var(--orange); }
.result-circle-poor      { border-color: var(--red); }

.result-big-score { font-size: 2rem; font-weight: 800; line-height: 1; }
.result-big-score span { font-size: 1rem; color: var(--text-secondary); }
.result-grade { font-size: 0.9rem; color: var(--text-secondary); }

.result-breakdown { flex: 1; min-width: 200px; }
.breakdown-item { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.breakdown-label { font-size: 0.78rem; color: var(--text-secondary); width: 80px; flex-shrink: 0; }
.progress-bar  { flex: 1; height: 8px; background: var(--bg-surface); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 4px; transition: width 0.6s; }
.pf-tajwid     { background: var(--purple); }
.pf-fluency    { background: var(--blue); }
.breakdown-val { font-size: 0.78rem; font-weight: 600; width: 36px; text-align: right; flex-shrink: 0; }

.result-meta-col { display: flex; flex-direction: column; gap: 0.4rem; }
.meta-item { font-size: 0.82rem; color: var(--text-secondary); }
.meta-item strong { color: var(--text-primary); }
.fluency-badge-lg { font-size: 0.85rem; padding: 0.35rem 0.9rem; display: inline-block; }

.text-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.text-col h4  { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.75rem;
                text-transform: uppercase; letter-spacing: 0.05em; }
.arabic-text  { font-family: var(--font-arab); font-size: 1.3rem; line-height: 2.2; text-align: right; }

.tajwid-rule-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.tajwid-rule-badge {
    padding: 0.6rem 1rem; border-radius: var(--radius-lg);
    display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
    border: 1px solid; min-width: 90px; text-align: center;
    opacity: 0.5; transition: opacity 0.2s;
}
.tajwid-rule-badge.has-issues { opacity: 1; }
.tajwid-blue   { background: var(--blue-dim);   border-color: var(--blue); }
.tajwid-purple { background: var(--purple-dim); border-color: var(--purple); }
.tajwid-teal   { background: var(--teal-dim);   border-color: var(--teal); }
.tajwid-orange { background: var(--orange-dim); border-color: var(--orange); }
.tajwid-green  { background: var(--green-dim);  border-color: var(--green); }

.rule-icon  { font-size: 1.4rem; }
.rule-name  { font-size: 0.75rem; font-weight: 600; }
.rule-count { font-size: 0.7rem; color: var(--text-secondary); }

.mistakes-list { display: flex; flex-direction: column; gap: 0.4rem; }
.mistake-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.75rem; border-radius: var(--radius);
    border-left: 3px solid transparent;
}
.mistake-num { font-weight: 700; color: var(--text-muted); min-width: 24px; font-size: 0.78rem; }
.mistake-type-tag {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem; border-radius: 4px;
    background: var(--bg-surface); color: var(--text-secondary);
    min-width: 68px; text-align: center; flex-shrink: 0;
}
.mistake-desc { flex: 1; font-size: 0.83rem; }
.severity-badge-critical { font-size: 0.7rem; color: var(--red);    font-weight: 600; flex-shrink: 0; }
.severity-badge-major    { font-size: 0.7rem; color: var(--orange); font-weight: 600; flex-shrink: 0; }
.severity-badge-minor    { font-size: 0.7rem; color: var(--blue);   font-weight: 600; flex-shrink: 0; }

.card-tips .card-header { border-color: rgba(201,162,39,0.3); }
.tip-item {
    padding: 0.65rem 0.85rem;
    background: var(--gold-dim);
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.full-audio-player { width: 100%; }
.result-body { display: flex; flex-direction: column; }
.result-actions {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
    margin-top: 0.5rem; padding-top: 1rem;
    padding-bottom: 0.5rem;
}

/* =============================================
   TABLES
============================================= */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 450px;
}
.data-table th {
    background: var(--bg-surface);
    padding: 0.65rem 0.9rem;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .row-highlight { background: var(--gold-dim) !important; }

.arabic-sm { font-family: var(--font-arab); font-size: 1.1rem; }

.score-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}
.score-pill-excellent { background: var(--green-dim);  color: #7ee787; }
.score-pill-good      { background: var(--blue-dim);   color: #79c0ff; }
.score-pill-fair      { background: var(--orange-dim); color: var(--orange); }
.score-pill-poor      { background: var(--red-dim);    color: #ff7b7a; }

/* =============================================
   LEADERBOARD
============================================= */
.leaderboard-page { max-width: 800px; }
.leaderboard-header { text-align: center; margin-bottom: 1.5rem; }
.leaderboard-header h2 { font-size: 1.5rem; }
.leaderboard-header p  { color: var(--text-secondary); }

.leaderboard-user { display: flex; align-items: center; gap: 0.6rem; }
.lb-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--gold); color: var(--bg-deep);
    display: grid; place-items: center;
    font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.you-tag {
    font-size: 0.68rem; padding: 0.1rem 0.5rem;
    background: var(--gold-dim); color: var(--gold);
    border-radius: 10px; border: 1px solid var(--gold);
}
.rank        { font-size: 1rem; font-weight: 700; }
.rank-gold   { font-size: 1.4rem; }
.rank-silver { font-size: 1.3rem; }
.rank-bronze { font-size: 1.2rem; }

.lb-score { display: flex; align-items: center; gap: 0.75rem; }
.lb-score-bar { height: 8px; background: var(--gold); border-radius: 4px; min-width: 4px; }
.lb-score span { font-weight: 600; font-size: 0.85rem; }

/* =============================================
   LEVEL BADGES
============================================= */
.level-badge { padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.level-beginner     { background: var(--blue-dim);   color: #79c0ff; }
.level-intermediate { background: var(--orange-dim); color: var(--orange); }
.level-advanced     { background: var(--green-dim);  color: #7ee787; }

/* =============================================
   TAJWID PAGE
============================================= */
.tajwid-page { max-width: 1000px; }
.tajwid-intro { margin-bottom: 1rem; }
.tajwid-group { margin-bottom: 1.25rem; }
.tajwid-group-header { background: var(--bg-surface); }
.tajwid-group-header h3 { margin-bottom: 0.2rem; }
.tajwid-group-header p  { font-size: 0.8rem; color: var(--text-secondary); font-weight: 400; }

.tajwid-rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.tajwid-rule-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: border-color 0.18s;
}
.tajwid-rule-card:hover { border-color: var(--gold); }
.tajwid-rule-name { font-weight: 600; margin-bottom: 0.4rem; }
.tajwid-example   { font-family: var(--font-arab); font-size: 1.5rem; color: var(--gold); margin-bottom: 0.4rem; }
.tajwid-rule-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6; }

/* =============================================
   ADMIN
============================================= */
.admin-page { max-width: 1200px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.lb-user    { display: flex; align-items: center; gap: 0.6rem; }
.page-back  { margin-bottom: 1rem; }

.student-profile .card-body {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.profile-avatar {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--gold); color: var(--bg-deep);
    display: grid; place-items: center;
    font-size: 1.5rem; font-weight: 700; flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-info h2 { font-size: 1.1rem; }
.profile-info p  { color: var(--text-secondary); font-size: 0.85rem; }
.profile-stats   { display: flex; gap: 1.5rem; flex-shrink: 0; }
.pstat { text-align: center; }
.pstat strong { display: block; font-size: 1.4rem; color: var(--gold); }
.pstat small  { font-size: 0.75rem; color: var(--text-secondary); }

/* =============================================
   MISC
============================================= */
.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }

.text-danger  { color: var(--red); }
.text-center  { text-align: center; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.p-4  { padding: 1.5rem; }

/* Landing */
.landing-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--topbar-h));
    padding: 1.5rem;
}
.landing-hero {
    text-align: center;
    max-width: 540px;
    width: 100%;
}
.landing-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.75rem; }
.landing-desc  { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.95rem; line-height: 1.7; }
.landing-features { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.75rem; margin-bottom: 2rem; }
.feature-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: center;
    transition: border-color 0.18s;
}
.feature-item:hover { border-color: var(--gold); }
.feature-icon { font-size: 1.5rem; display: block; margin-bottom: 0.5rem; }
.feature-item strong { font-size: 0.82rem; display: block; margin-bottom: 0.3rem; }
.feature-item p { font-size: 0.75rem; color: var(--text-secondary); }
.landing-cta { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* Toast */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 1rem + var(--safe-bottom));
    right: 1rem; left: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.875rem;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 480px;
    margin: 0 auto;
}
@media (min-width: 768px) {
    .toast { left: auto; min-width: 280px; bottom: 1.5rem; }
}
.toast.show    { transform: translateY(0); opacity: 1; }
.toast-success { border-color: var(--green); }
.toast-error   { border-color: var(--red); }
.toast-close   { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; flex-shrink: 0; }

/* =============================================
   RESPONSIVE — Tablet (≤1100px)
============================================= */
@media (max-width: 1100px) {
    .practice-layout { grid-template-columns: 1fr; }
    .admin-grid      { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .text-compare { grid-template-columns: 1fr; }
}

/* =============================================
   RESPONSIVE — Mobile (≤768px)
============================================= */
@media (max-width: 768px) {

    /* Sidebar: slide-in drawer */
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-w), 85vw);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close-btn { display: flex; }

    /* Hamburger: show */
    .sidebar-toggle { display: flex; }

    /* Main content: full width + bottom nav space */
    .main-wrap {
        margin-left: 0;
        max-width: 100vw;
        padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    }

    /* Bottom navigation: show */
    .bottom-nav { display: flex; }

    /* Topbar */
    .topbar { padding: 0 0.9rem; }

    /* Page content */
    .page-content { padding: 0.85rem; }

    /* Stats: 2 columns */
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

    /* Quick action: compact */
    .quick-action-card { padding: 1.1rem; }
    .qa-deco { display: none; }

    /* Score row: stack */
    .result-score-row { flex-direction: column; align-items: flex-start; gap: 1rem; }

    /* Landing: full width */
    .landing-page { padding: 1rem; min-height: auto; padding-top: 2rem; }
    .landing-features { grid-template-columns: 1fr; }
    .landing-title { font-size: 1.25rem; }

    /* Auth */
    .auth-container { padding: 0 0.5rem; }
    .auth-card { padding: 1.25rem; border-radius: var(--radius-lg); }
    .auth-brand-name { font-size: 1.5rem; }

    /* Admin grid: single column */
    .admin-grid { grid-template-columns: 1fr; }

    /* Search form in card header */
    .card-header { flex-wrap: wrap; gap: 0.5rem; }
    .search-form .form-control { width: 130px; }

    /* Practice page: stack panels */
    .practice-layout { grid-template-columns: 1fr; gap: 0.85rem; }
    .recorder-card .card-body { padding: 1rem 0.85rem; }
    .timer-display { font-size: 1.8rem; }
    .btn-record, .btn-stop { padding: 0.7rem 1.5rem; }
    .btn-analyze { min-height: 56px; font-size: 1.05rem; }

    /* Result actions */
    .result-actions { gap: 0.5rem; }
    .result-actions .btn { flex: 1; min-width: 0; font-size: 0.8rem; padding: 0.6rem 0.5rem; }

    /* Score ring */
    .score-ring { width: 44px; height: 44px; font-size: 0.78rem; }

    /* Tajwid rules grid */
    .tajwid-rules-grid { grid-template-columns: 1fr 1fr; }

    /* Session items */
    .session-item { gap: 0.6rem; padding: 0.65rem 0.75rem; }
    .session-date { display: none; }

    /* Leaderboard */
    .leaderboard-header h2 { font-size: 1.2rem; }
}

/* =============================================
   RESPONSIVE — Small mobile (≤400px)
============================================= */
@media (max-width: 400px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 0.85rem 0.6rem; }
    .stat-value { font-size: 1.3rem; }
    .tajwid-rules-grid { grid-template-columns: 1fr; }
    .selector-row { flex-direction: column; }
    .ayah-arabic { font-size: 1.4rem; }
    .landing-features { grid-template-columns: 1fr; }
}

/* =============================================
   PRINT
============================================= */
@media print {
    .sidebar, .topbar, .bottom-nav { display: none !important; }
    .main-wrap { margin-left: 0 !important; padding-bottom: 0 !important; }
    body { background: white; color: black; }
}
