/* Material Design 3 — free study pages (website only) */
:root {
    --md-primary: #1a56db;
    --md-primary-dark: #1240a8;
    --md-on-primary: #ffffff;
    --md-secondary: #f26522;
    --md-surface: #f7f8fc;
    --md-surface-card: #ffffff;
    --md-on-surface: #1c1b1f;
    --md-on-surface-variant: #49454f;
    --md-outline: #cac4d0;
    --md-success: #146c43;
    --md-radius: 16px;
    --md-radius-lg: 28px;
    --md-elev-1: 0 1px 3px rgba(28, 27, 31, .12), 0 1px 2px rgba(28, 27, 31, .08);
    --md-elev-2: 0 4px 8px rgba(28, 27, 31, .12), 0 2px 4px rgba(28, 27, 31, .08);
    --md-elev-3: 0 8px 16px rgba(26, 86, 219, .16), 0 4px 8px rgba(28, 27, 31, .08);
}

.md-study-page {
    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
    color: var(--md-on-surface);
}

.md-read-page {
    padding-bottom: 88px;
}

.md-hero {
    background: linear-gradient(135deg, #0b1f3a 0%, #12355b 55%, #1a56db 140%);
    color: #fff;
    border-radius: var(--md-radius-lg);
    padding: 28px 28px 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--md-elev-2);
    margin-bottom: 20px;
}

.md-hero::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    right: -40px;
    top: -60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    pointer-events: none;
}

.md-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: .78rem;
    font-weight: 500;
    letter-spacing: .02em;
}

.md-chip.solid {
    background: #e8f0fe;
    color: var(--md-primary);
}

.md-chip.success {
    background: #d1fae5;
    color: var(--md-success);
}

.md-chip.warn {
    background: #fff7ed;
    color: #c2410c;
}

.md-hero h1 {
    font-size: 1.85rem;
    font-weight: 700;
    margin: 12px 0 8px;
    line-height: 1.25;
}

.md-hero p {
    margin: 0;
    opacity: .88;
    max-width: 52rem;
    font-size: .98rem;
}

.md-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0 8px;
}

.md-stat {
    background: var(--md-surface-card);
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
    padding: 14px 18px;
    min-width: 110px;
    flex: 1;
}

.md-stat strong {
    display: block;
    font-size: 1.35rem;
    color: var(--md-primary);
    font-weight: 700;
}

.md-stat span {
    font-size: .75rem;
    color: var(--md-on-surface-variant);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.md-login-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: var(--md-radius);
    padding: 14px 18px;
    margin: 8px 0 20px;
}

.md-login-hint p {
    margin: 0;
    color: #9a3412;
    font-weight: 500;
}

.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none !important;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.md-btn:hover {
    transform: translateY(-1px);
}

.md-btn-filled {
    background: var(--md-primary);
    color: #fff !important;
    box-shadow: var(--md-elev-1);
}

.md-btn-filled:hover {
    background: var(--md-primary-dark);
    color: #fff !important;
}

.md-btn-tonal {
    background: #e8f0fe;
    color: var(--md-primary) !important;
}

.md-btn-tonal:hover {
    background: #d2e3fc;
}

.md-btn-orange {
    background: var(--md-secondary);
    color: #fff !important;
}

.md-btn-outline {
    background: transparent;
    color: var(--md-primary) !important;
    border: 1px solid var(--md-outline);
}

.md-card {
    background: var(--md-surface-card);
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-elev-1);
    overflow: hidden;
}

.md-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.md-subject-card,
.md-chapter-card {
    background: var(--md-surface-card);
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    color: inherit !important;
    transition: transform .2s ease, box-shadow .2s ease;
    min-height: 100%;
}

.md-subject-card:hover,
.md-chapter-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--md-elev-3);
}

.md-subject-media {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 100%;
    background: #eef2ff;
    overflow: hidden;
}

.md-subject-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.md-subject-media i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.md-card-body {
    padding: 16px 16px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.md-card-body h3,
.md-card-body h6 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--md-on-surface);
    line-height: 1.35;
}

.md-card-body p {
    color: var(--md-on-surface-variant);
    font-size: .85rem;
    line-height: 1.55;
    margin: 0 0 14px;
    flex: 1;
}

.md-chapter-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.md-num {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #e8f0fe;
    color: var(--md-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.md-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.md-overview {
    background: var(--md-surface-card);
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-elev-1);
    padding: 22px;
    margin-bottom: 20px;
}

.md-overview h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 10px;
}

.md-read-hero .md-progress {
    margin-top: 14px;
    font-size: .85rem;
    opacity: .9;
}

.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.md-toolbar .form-select {
    border-radius: 999px;
    font-size: .85rem;
    max-width: 180px;
}

.md-paper {
    background: #fff;
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-elev-1);
    padding: 28px 28px 36px;
    margin-bottom: 20px;
}

.md-notes {
    font-size: 1.08rem;
    line-height: 1.8;
    color: #1b2430;
    max-height: none;
    overflow: visible;
}

.md-notes h1, .md-notes h2, .md-notes h3, .md-notes h4 {
    color: #0b1f3a;
    font-weight: 700;
    margin-top: 1.3em;
}

.md-notes p { margin-bottom: 1em; }
.md-notes img { max-width: 100%; height: auto; border-radius: 12px; }

.md-nav-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 8px 0 22px;
}

.md-nav-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
    padding: 14px 16px;
    text-decoration: none !important;
    color: inherit !important;
    min-height: 84px;
}

.md-nav-card.disabled {
    opacity: .45;
    pointer-events: none;
}

.md-nav-card:hover {
    box-shadow: var(--md-elev-3);
}

.md-nav-card small {
    display: block;
    color: var(--md-on-surface-variant);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .7rem;
}

.md-nav-card strong {
    display: block;
    font-size: .95rem;
    line-height: 1.3;
}

.md-nav-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e8f0fe;
    color: var(--md-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.md-bottom-nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #fff;
    border-radius: 999px;
    box-shadow: var(--md-elev-3);
    padding: 8px 10px;
    width: calc(100% - 24px);
    max-width: 720px;
}

.md-bottom-nav .md-btn {
    min-width: 120px;
}

.md-bottom-nav .md-mid {
    font-size: .82rem;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    text-align: center;
}

.md-mock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.md-mock-item {
    background: #fff;
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
    padding: 16px 12px;
    text-align: center;
    text-decoration: none !important;
    color: inherit !important;
}

.md-mock-item:hover { box-shadow: var(--md-elev-3); }
.md-mock-item.attempt-today { background: #fff7ed; }

.md-status {
    font-size: .85rem;
    opacity: .88;
    margin-top: 8px;
}

.md-empty {
    text-align: center;
    padding: 36px 16px;
    background: #fff;
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-elev-1);
}

@media (max-width: 768px) {
    .md-hero { padding: 22px 18px; }
    .md-hero h1 { font-size: 1.4rem; }
    .md-paper { padding: 18px 16px 24px; }
    .md-nav-pair { grid-template-columns: 1fr; }
    .md-bottom-nav .md-btn { min-width: 0; flex: 1; padding: 10px 12px; }
    .md-grid { grid-template-columns: 1fr; }
}

/* Free Study split: 80% notes, 20% controls */
body:has(.md-study-split) {
    overflow: hidden;
    background: #f3f5f9;
}

body:has(.md-study-split) > .container-fluid {
    padding: 8px 10px 6px !important;
    height: calc(100dvh - 56px);
    max-height: calc(100dvh - 56px);
    overflow: hidden;
}

body:has(.md-study-split) .footer {
    display: none !important;
}

.md-study-split {
    height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 80fr) minmax(132px, 20fr);
    gap: 8px;
}

.md-study-content {
    min-height: 0;
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--md-elev-1);
    padding: 10px 12px 16px;
}

.md-study-split .sc-path-bar {
    margin-bottom: 8px;
    border-radius: 14px;
    padding: 8px 10px;
}

.md-study-split .sc-path-bar h1 {
    font-size: .98rem;
}

.md-chapter-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.md-chapter-head img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 3px;
    flex-shrink: 0;
}

.md-chapter-copy {
    min-width: 0;
    flex: 1;
}

.md-chapter-crumb {
    font-size: .75rem;
    color: var(--md-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-chapter-head h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #0b1f3a;
    line-height: 1.25;
}

.md-chip-soft {
    flex-shrink: 0;
    background: #d1fae5;
    color: #146c43;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: .72rem;
    font-weight: 700;
}

.md-mini-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: .8rem;
}

.md-mini-nav a {
    color: var(--md-primary);
    font-weight: 700;
    text-decoration: none !important;
}

.md-mini-nav .disabled {
    opacity: .4;
}

.md-study-content .md-notes {
    font-size: 1.02rem;
    line-height: 1.75;
}

.md-study-content .md-notes table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    margin: 10px 0 16px;
}

.md-study-content .md-notes th,
.md-study-content .md-notes td {
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 12px;
}

.md-study-content .md-notes tr:last-child th,
.md-study-content .md-notes tr:last-child td {
    border-bottom: none;
}

.md-study-controls {
    min-height: 0;
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--md-elev-2);
    padding: 8px 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.md-ctrl-audio {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(92px, 1.4fr);
    align-items: center;
    gap: 4px;
}

.md-round-wrap span { line-height: 1; }

.md-round-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: .68rem;
    color: var(--md-on-surface-variant);
    font-weight: 600;
}

.md-round {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.md-round-play { background: #f26522; color: #fff; }
.md-round-pause { background: #0b1f3a; color: #fff; }
.md-round-resume { background: #eef2f7; color: #0b1f3a; }
.md-round-stop { background: #eef2f7; color: #334155; }

.md-ctrl-speed {
    min-width: 0;
}

.md-ctrl-speed-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-weight: 700;
    color: #0b1f3a;
}

.md-ctrl-speed input[type="range"] {
    width: 100%;
    accent-color: #f26522;
}

.md-ctrl-speed .form-select {
    display: none;
}

.md-ctrl-files {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.35fr;
    gap: 6px;
}

.md-dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    padding: 0 8px;
    white-space: nowrap;
}

.md-dock-orange { background: #f26522; color: #fff !important; }
.md-dock-navy { background: #0b1f3a; color: #fff !important; }
.md-dock-soft { background: #d6e4f7; color: #0b1f3a !important; }

.md-ctrl-mocks {
    display: flex;
    gap: 6px;
}

.md-study-controls .md-mock-item {
    flex: 1;
    min-width: 0;
    padding: 6px 4px;
    border-radius: 10px;
    box-shadow: none;
    border: 1px solid #e2e8f0;
}

.md-study-controls .md-mock-item strong {
    font-size: .78rem;
}

.md-ctrl-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .72rem;
    color: var(--md-on-surface-variant);
    min-height: 14px;
}

.md-ctrl-meta .md-link-btn { display: none; }

.md-ctrl-meta #audioStatus {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-link-btn {
    background: none;
    border: 0;
    color: var(--md-primary);
    font-weight: 700;
    font-size: .72rem;
    padding: 0;
    text-decoration: none !important;
    cursor: pointer;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .md-ctrl-files { grid-template-columns: 1fr 1fr 1fr 1.2fr; }
    .md-dock-btn { font-size: .68rem; height: 32px; gap: 4px; }
    .md-round { width: 36px; height: 36px; }
}

@media print {
    .md-toolbar, .md-bottom-nav, .md-nav-pair, .sc-no-print, nav, footer { display: none !important; }
    .md-paper, .md-hero { box-shadow: none !important; }
    body:has(.md-study-split) { overflow: visible !important; height: auto !important; }
    body:has(.md-study-split) > .container-fluid {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }
    .md-study-split { display: block; height: auto; }
    .md-study-content { overflow: visible; height: auto; box-shadow: none; }
    .md-study-controls { display: none !important; }
}
