/* =========================================================================
   PUA design system
   Dark, modern, confident. Rose/crimson accent on near-black.
   ========================================================================= */
:root {
    --bg: #0a0a0f;
    --bg-2: #12121a;
    --surface: #16161f;
    --surface-2: #1d1d29;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(225, 29, 72, 0.4);
    --text: #f5f5f7;
    --text-dim: #a1a1aa;
    --text-faint: #6b6b76;
    --accent: #e11d48;
    --accent-2: #fb7185;
    --accent-grad: linear-gradient(135deg, #e11d48, #fb7185);
    --gold: #f5c451;
    --green: #22c55e;
    --red: #ef4444;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    --nav-h: 68px;
}

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

/* html carries the 100% height; body must grow with content so its
   padding-bottom lands AFTER the page content (bottom-nav clearance). */
html { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(1200px 800px at 50% -10%, #1a0f18 0%, var(--bg) 55%);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
    /* Clearance so the fixed bottom nav never covers content or buttons */
    padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}

a { color: inherit; text-decoration: none; }

.container {
    max-width: 780px;
    margin: 0 auto;
    padding: 20px 18px 40px;
}

/* ---- Top bar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top));
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
}
/* Contents align with the .container width on wide screens */
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 780px;
    margin: 0 auto;
}
.brand {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 0.5px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.credit-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(225, 29, 72, 0.14);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}
.credit-pill b { color: var(--accent-2); }
.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.admin-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #7dd3fc;
}
.admin-pill[hidden] { display: none; }

/* ---- Headings ---- */
h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 21px; font-weight: 700; margin-bottom: 14px; }
h3 { font-size: 17px; font-weight: 700; }
.subtitle { color: var(--text-dim); font-size: 15px; margin-top: 4px; }
.section-label {
    text-transform: uppercase;
    letter-spacing: 1.4px;
    font-size: 12px;
    color: var(--text-faint);
    font-weight: 700;
    margin: 28px 0 12px;
}

/* ---- Cards ---- */
.card {
    background: linear-gradient(160deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    background: linear-gradient(160deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    min-height: 132px;
}
.tile:active { transform: scale(0.98); }
.tile:hover { border-color: var(--border-strong); box-shadow: 0 14px 32px rgba(225,29,72,0.14); }
.tile .icon { font-size: 28px; }
.tile .title { font-weight: 700; font-size: 16px; }
.tile .desc { font-size: 13px; color: var(--text-dim); }
.tile.locked { opacity: 0.55; }
.tile .badge {
    position: absolute; top: 14px; right: 14px;
    font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 4px 8px; border-radius: 999px;
    background: rgba(245, 196, 81, 0.16); color: var(--gold);
    border: 1px solid rgba(245, 196, 81, 0.3);
}
.tile .badge.soon { background: rgba(255,255,255,0.06); color: var(--text-faint); border-color: var(--border); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    background: var(--accent-grad);
    color: #fff;
}
.btn:active { transform: scale(0.98); }
.btn:hover { box-shadow: 0 12px 28px rgba(225, 29, 72, 0.35); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.btn.success { background: linear-gradient(135deg, #22c55e, #15803d); }
.btn.inline { width: auto; padding: 10px 18px; font-size: 14px; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; font-weight: 600; }
.input, select.input, textarea.input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text-faint); }
textarea.input { resize: vertical; min-height: 90px; }

/* ---- Alerts ---- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert.error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert.success { background: rgba(34, 197, 94, 0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.alert.info { background: rgba(59, 130, 246, 0.12); color: #93c5fd; border: 1px solid rgba(59,130,246,0.25); }
.alert.warn { background: rgba(245, 196, 81, 0.12); color: #fcd34d; border: 1px solid rgba(245,196,81,0.25); }

/* ---- Progress ---- */
.progress { height: 8px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-grad); border-radius: 999px; transition: width 0.4s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }

/* ---- Lists ---- */
.list-row {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    transition: border-color 0.15s ease;
}
.list-row:hover { border-color: var(--border-strong); }
.list-row .num {
    width: 34px; height: 34px; flex: 0 0 34px;
    display: grid; place-items: center;
    border-radius: 50%; font-weight: 800; font-size: 14px;
    background: rgba(225,29,72,0.14); color: var(--accent-2);
    border: 1px solid var(--border-strong);
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow .t { font-weight: 600; font-size: 15px; }
.list-row .grow .s { font-size: 13px; color: var(--text-dim); }
.list-row.done .num { background: rgba(34,197,94,0.16); color: #86efac; border-color: rgba(34,197,94,0.3); }
.list-row.locked { opacity: 0.5; }

/* ---- Course module headers ---- */
.module-head {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    margin: 30px 0 14px;
    box-shadow: var(--shadow);
}
.module-head img { width: 100%; display: block; aspect-ratio: 16 / 7; object-fit: cover; }
.module-head .mh-text {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 40px 18px 14px;
    background: linear-gradient(transparent, rgba(5, 5, 9, 0.94));
}
.module-head .mh-kicker {
    text-transform: uppercase; letter-spacing: 1.4px;
    font-size: 11px; font-weight: 700; color: var(--accent-2);
}
.module-head .mh-title { font-size: 20px; font-weight: 800; letter-spacing: -0.2px; }
.module-head .mh-desc { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ---- Lesson body (rich course content) ---- */
/* ---- Lesson "Listen" (TTS narration) ---- */
.listen-bar { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; flex-wrap: wrap; }
.listen-btn { width: auto; padding: 11px 20px; }
.listen-btn .ic { font-size: 17px; line-height: 1; }
.listen-btn.playing { background: var(--accent-grad); border-color: transparent; }
.listen-hint { font-size: 13px; color: var(--text-faint); }
.lesson-admin-audio { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.admin-audio { height: 36px; max-width: 240px; }
.lesson-script { flex-basis: 100%; margin: 2px 0 4px; }
.lesson-script[hidden] { display: none; }
.script-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.script-actions code { background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.lesson-hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin: 16px 0; }
.lesson-hero img { width: 100%; display: block; aspect-ratio: 16 / 8; object-fit: cover; }
.lesson-body { font-size: 15.5px; }
.lesson-body h3 { margin: 26px 0 10px; font-size: 18px; color: var(--accent-2); }
.lesson-body h3:first-child { margin-top: 0; }
.lesson-body p { margin: 12px 0; }
.lesson-body ul, .lesson-body ol { margin: 12px 0 12px 22px; }
.lesson-body li { margin: 7px 0; }
.lesson-body strong { color: var(--text); }
.lesson-body em { color: var(--accent-2); font-style: italic; }
.lesson-body blockquote {
    margin: 14px 0; padding: 12px 16px;
    border-left: 3px solid var(--accent);
    background: rgba(225, 29, 72, 0.07);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-dim); font-style: italic;
}
.lesson-body img { width: 100%; border-radius: var(--radius-sm); margin: 14px 0; }
.lesson-body table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.lesson-body th, .lesson-body td { padding: 9px 10px; border: 1px solid var(--border); text-align: left; }
.lesson-body th { background: rgba(255, 255, 255, 0.04); color: var(--text-dim); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.6px; }

/* Callout boxes used inside lesson bodies */
.callout {
    margin: 16px 0; padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    border-left-width: 3px;
    font-size: 14.5px;
}
.callout > b:first-child {
    display: block; margin-bottom: 5px;
    font-size: 11.5px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 1.1px;
}
.callout.tip { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.callout.tip > b:first-child { color: #93c5fd; }
.callout.drill { border-left-color: var(--green); background: rgba(34, 197, 94, 0.07); }
.callout.drill > b:first-child { color: #86efac; }
.callout.example { border-left-color: var(--gold); background: rgba(245, 196, 81, 0.07); }
.callout.example > b:first-child { color: var(--gold); }
.callout.warn { border-left-color: var(--red); background: rgba(239, 68, 68, 0.07); }
.callout.warn > b:first-child { color: #fca5a5; }

/* ---- Chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 9px 14px; border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 14px; cursor: pointer; transition: all 0.15s ease;
}
.chip.active { background: rgba(225,29,72,0.16); border-color: var(--border-strong); color: var(--accent-2); }

/* ---- Bottom nav ---- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 60;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    justify-content: center;
    background: rgba(14, 14, 20, 0.92);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
}
.bottom-nav a {
    flex: 1;
    max-width: 156px; /* 780px container / 5 items */
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    color: var(--text-faint);
    font-weight: 600;
}
.bottom-nav a .ic { font-size: 21px; line-height: 1; }
.bottom-nav a.active { color: var(--accent-2); }

/* ---- Auth pages ---- */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 40px 20px; }
.auth-logo { text-align: center; margin-bottom: 8px; font-size: 34px; font-weight: 900; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-tag { text-align: center; color: var(--text-dim); margin-bottom: 30px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text-dim); font-size: 14px; }
.auth-switch a { color: var(--accent-2); font-weight: 600; }

/* ---- Misc ---- */
.center { text-align: center; }
.muted { color: var(--text-dim); }
.spacer { height: 20px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.hidden { display: none !important; }
.pill-score {
    display: inline-grid; place-items: center;
    width: 96px; height: 96px; border-radius: 50%;
    font-size: 34px; font-weight: 900;
    border: 4px solid var(--accent); color: #fff;
    background: rgba(225,29,72,0.1);
}
.stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--text-dim); }

.spinner {
    width: 20px; height: 20px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff;
    animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 620px) {
    .tile-grid { grid-template-columns: repeat(3, 1fr); }
}
