.md-page {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px;
    line-height: 1.55;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1a1a1a;
}

.md-page-image-only {
    max-width: 980px;
    margin: 0 auto;
    padding: 12px;
    text-align: center;
}

.md-page-image-only img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.md-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e8e8e8;
}

.md-title {
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.1;
    margin: 0 0 12px 0;
    color: #1a237e;
    font-weight: 700;
}

.md-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: #455a64;
    margin: 0;
    font-weight: 400;
}

.md-section {
    margin: 24px 0;
}

.md-section-title {
    font-size: clamp(1.3rem, 3vw, 2rem);
    margin: 0 0 12px 0;
    color: #283593;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.md-paragraph {
    margin: 12px 0;
    line-height: 1.7;
    font-size: 1rem;
}

.md-lead {
    font-size: 1.15rem;
    line-height: 1.6;
    color: #37474f;
    margin: 0 0 16px 0;
}

.md-grid {
    display: grid;
    gap: 20px;
    margin: 16px 0;
}

.md-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.md-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.md-figure {
    --img-w-mobile: 100%;
    --img-w-tablet: 80%;
    --img-w-desktop: 60%;
    margin: 16px 0;
    text-align: center;
}

.md-image,
.md-figure img {
    width: var(--img-w-desktop);
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.md-figure img[style*="width"] {
    max-width: 100%;
    height: auto;
}

.md-caption {
    font-size: 0.9rem;
    margin-top: 8px;
    color: #555;
    font-style: italic;
}

.md-caption[hidden] {
    display: none;
}

/* Alignment */
.md-align-left { text-align: left; }
.md-align-left .md-image { margin: 0; }
.md-align-center { text-align: center; }
.md-align-center .md-image { margin: 0 auto; }
.md-align-right { text-align: right; }
.md-align-right .md-image { margin: 0 0 0 auto; }

/* Fit mode */
.md-img-contain .md-image { object-fit: contain; }
.md-img-cover .md-image { object-fit: cover; }

/* Image rows (side-by-side) */
.md-image-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.md-image-row > .md-figure {
    margin: 0;
}

.md-cols-2 > .md-figure {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
}

.md-cols-3 > .md-figure {
    flex: 1 1 calc(33.333% - 11px);
    min-width: 0;
}

.md-note {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #e3f2fd;
    border-left: 4px solid #1976d2;
}

.md-info {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #e8f5e9;
    border-left: 4px solid #388e3c;
}

.md-warning {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #fff3e0;
    border-left: 4px solid #f57c00;
}

.md-definition {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #f3e5f5;
    border-left: 4px solid #7b1fa2;
}

.md-example {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #fce4ec;
    border-left: 4px solid #c2185b;
}

.md-exercise {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #e0f7fa;
    border-left: 4px solid #00838f;
}

.md-question {
    padding: 16px 20px;
    border-radius: 14px;
    margin: 18px 0;
    background: #fffde7;
    border-left: 4px solid #f9a825;
}

.md-list {
    margin: 12px 0;
    padding-left: 24px;
}

.md-list-item {
    margin: 6px 0;
    line-height: 1.6;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.95rem;
}

.md-table th,
.md-table td {
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.md-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.md-table tr:nth-child(even) {
    background: #fafafa;
}

.md-highlight {
    background: linear-gradient(120deg, #fff9c4 0%, #fff176 100%);
    padding: 2px 6px;
    border-radius: 4px;
}

.md-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85rem;
    color: #757575;
    text-align: center;
}

/* Tablet breakpoint */
@media (min-width: 769px) and (max-width: 1024px) {
    .md-figure .md-image,
    .md-figure img {
        width: var(--img-w-tablet) !important;
    }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
    .md-page {
        padding: 14px;
    }

    .md-figure .md-image,
    .md-figure img {
        width: var(--img-w-mobile) !important;
    }

    .md-image-row {
        flex-direction: column;
    }

    .md-cols-2 > .md-figure,
    .md-cols-3 > .md-figure {
        flex: 1 1 100%;
    }

    .md-grid-2,
    .md-grid-3 {
        grid-template-columns: 1fr;
    }

    .md-note,
    .md-info,
    .md-warning,
    .md-definition,
    .md-example,
    .md-exercise,
    .md-question {
        padding: 12px 14px;
        border-radius: 10px;
    }

    .md-table {
        min-width: 0 !important;
        font-size: 0.85rem;
    }

    .md-table th,
    .md-table td {
        padding: 6px 8px;
    }

    /* Responsive card mode for tables on small screens */
    .md-table.md-card-mode,
    .md-table-responsive,
    .md-table-wrapper > .md-table {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        border: none !important;
    }

    .md-table.md-card-mode thead,
    .md-table-responsive thead,
    .md-table-wrapper > .md-table thead {
        display: none !important;
    }

    .md-table.md-card-mode tbody,
    .md-table-responsive tbody,
    .md-table-wrapper > .md-table tbody {
        display: block !important;
        width: 100% !important;
    }

    .md-table.md-card-mode tr,
    .md-table-responsive tr,
    .md-table-wrapper > .md-table tr {
        display: block !important;
        margin-bottom: 16px !important;
        background: #ffffff !important;
        border: 1px solid #dcdcdc !important;
        border-radius: 8px !important;
        padding: 12px 14px !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) !important;
    }

    .md-table.md-card-mode tbody th,
    .md-table-responsive tbody th,
    .md-table-wrapper > .md-table tbody th {
        display: block !important;
        width: 100% !important;
        background: #eef6f9 !important;
        color: #007c99 !important;
        font-weight: 700 !important;
        font-size: 1rem !important;
        padding: 8px 10px !important;
        border-radius: 6px !important;
        margin-bottom: 8px !important;
        text-align: left !important;
        border: none !important;
    }

    .md-table.md-card-mode td,
    .md-table-responsive td,
    .md-table-wrapper > .md-table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        padding: 8px 0 !important;
        border: none !important;
        border-bottom: 1px dashed #ececec !important;
        font-size: 0.95rem !important;
        line-height: 1.4 !important;
        gap: 12px !important;
        text-align: right !important;
    }

    .md-table.md-card-mode td:last-child,
    .md-table-responsive td:last-child,
    .md-table-wrapper > .md-table td:last-child {
        border-bottom: none !important;
    }

    .md-table.md-card-mode td::before,
    .md-table-responsive td::before,
    .md-table-wrapper > .md-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #007c99;
        text-align: left;
        margin-right: 8px;
        flex-shrink: 0;
        min-width: 90px;
        max-width: 48%;
    }

    .md-table.md-card-mode td:not([data-label]),
    .md-table-responsive td:not([data-label]),
    .md-table-wrapper > .md-table td:not([data-label]) {
        display: block !important;
        text-align: left !important;
    }

    .md-table.md-card-mode td:empty,
    .md-table-responsive td:empty,
    .md-table-wrapper > .md-table td:empty {
        display: none !important;
    }

    div[role="region"]:has(> .md-table.md-card-mode),
    div[role="region"]:has(> .md-table-responsive),
    div[role="region"]:has(> .md-table-wrapper > .md-table),
    .md-table-wrapper {
        overflow-x: visible !important;
    }
}

@media (max-width: 480px) {
    .md-title {
        font-size: 1.5rem;
    }

    .md-section-title {
        font-size: 1.2rem;
    }
}

