:root {
    --expert-print-ink: #222;
    --expert-print-muted: #5e6266;
    --expert-print-line: #c9c9c4;
    --expert-print-gold: #f5b800;
    --expert-print-soft: #f7f5ed;
}

body.portal-page {
    margin: 0;
    color: var(--expert-print-ink);
    background: #e9ecef;
    font-family: 'Noto Sans Thai', Tahoma, sans-serif;
}

.expert-print-page { min-height: 100vh; padding: 22px; }
.expert-print-toolbar { width: min(100%, 210mm); margin: 0 auto 14px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: 8px; background: #242424; box-shadow: 0 4px 18px rgba(0, 0, 0, .12); }
.expert-print-toolbar a, .expert-print-toolbar button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px; border: 1px solid #6f6f6f; border-radius: 5px; color: #fff; background: transparent; font: inherit; font-size: .82rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.expert-print-toolbar button, .expert-print-format a.is-active { border-color: var(--expert-print-gold); background: var(--expert-print-gold); color: #211a00; }
.expert-print-format { display: inline-flex; gap: 5px; }
.expert-print-sheet { width: min(100%, 210mm); margin: 0 auto; padding: 14mm 15mm 13mm; background: #fff; box-shadow: 0 5px 24px rgba(0, 0, 0, .12); }
.expert-print-document-header { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 3px solid var(--expert-print-gold); }
.expert-print-logo { width: 21mm; height: 27mm; flex: 0 0 21mm; overflow: hidden; display: block; }
.expert-print-logo img { width: auto; height: 100%; max-width: none; display: block; }
.expert-print-document-header p, .expert-print-document-header h1, .expert-print-document-header span { margin: 0; }
.expert-print-document-header p { font-size: 10pt; font-weight: 700; }
.expert-print-document-header h1 { margin-top: 1px; font-size: 18pt; line-height: 1.3; font-weight: 800; }
.expert-print-document-header div > span { color: var(--expert-print-muted); font-size: 8pt; letter-spacing: .08em; }
.expert-print-identity { display: grid; grid-template-columns: 34mm minmax(0, 1fr); gap: 8mm; align-items: center; padding: 9mm 0 7mm; }
.expert-print-avatar { width: 34mm; height: 34mm; overflow: hidden; display: grid; place-items: center; border: 1px solid #aaa; border-radius: 50%; color: #777; background: #eee; font-size: 30pt; }
.expert-print-avatar img { width: 100%; height: 100%; object-fit: cover; }
.expert-print-kicker { margin: 0 0 2px; color: #846400; font-size: 7.5pt; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.expert-print-identity h2 { margin: 0; font-size: 17pt; line-height: 1.35; font-weight: 800; }
.expert-print-affiliation { margin: 2px 0 7px; color: var(--expert-print-muted); font-size: 9.5pt; }
.expert-print-topics { display: flex; flex-wrap: wrap; gap: 4px; }
.expert-print-topics span { padding: 2px 6px; border: 1px solid #d4c26f; border-radius: 10px; background: #fff8d8; font-size: 7.2pt; }
.expert-print-section { margin-top: 7mm; }
.expert-print-section > h2, .expert-print-section-title { margin: 0 0 4mm; padding-bottom: 2mm; border-bottom: 2px solid var(--expert-print-gold); }
.expert-print-section > h2, .expert-print-section-title h2 { margin: 0; font-size: 12pt; font-weight: 800; }
.expert-print-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.expert-print-section-title span { color: var(--expert-print-muted); font-size: 7.5pt; white-space: nowrap; }
.expert-print-summary { margin: 0; font-size: 9pt; line-height: 1.7; }
.expert-print-list { display: grid; gap: 3mm; }
.expert-print-record { padding-left: 4mm; border-left: 1.2mm solid #d9d5c7; break-inside: avoid; page-break-inside: avoid; }
.expert-print-record h3 { margin: 0; font-size: 9.3pt; line-height: 1.55; font-weight: 700; }
.expert-print-record p { margin: 1mm 0 0; color: var(--expert-print-muted); font-size: 8pt; line-height: 1.55; overflow-wrap: anywhere; }
.expert-print-record-meta { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 1mm; }
.expert-print-record-meta span { padding: 1px 5px; background: var(--expert-print-soft); color: #665014; font-size: 6.8pt; font-weight: 700; }
.expert-print-work { padding-top: 2mm; padding-bottom: 2mm; border-top: 1px solid #e7e5de; border-right: 1px solid #e7e5de; border-bottom: 1px solid #e7e5de; }
.expert-print-teaching { padding-top: 1mm; padding-bottom: 1mm; }
.expert-print-url a { color: inherit; text-decoration: none; }
.expert-print-contact > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2mm 6mm; }
.expert-print-contact span { color: var(--expert-print-muted); font-size: 8pt; overflow-wrap: anywhere; }
.expert-print-contact strong { color: var(--expert-print-ink); }
.expert-print-footer { margin-top: 9mm; padding-top: 3mm; display: grid; grid-template-columns: 1fr auto auto; gap: 6mm; border-top: 1px solid var(--expert-print-line); color: var(--expert-print-muted); font-size: 6.8pt; }
.expert-print-footer div { display: grid; }
.expert-print-footer strong { color: var(--expert-print-ink); }
.expert-print-footer span { overflow-wrap: anywhere; }

@media (max-width: 720px) {
    .expert-print-page { padding: 10px; }
    .expert-print-toolbar { align-items: stretch; flex-direction: column; }
    .expert-print-format { display: grid; grid-template-columns: 1fr 1fr; }
    .expert-print-sheet { padding: 9mm 7mm; }
    .expert-print-identity { grid-template-columns: 28mm minmax(0, 1fr); gap: 5mm; }
    .expert-print-avatar { width: 28mm; height: 28mm; }
    .expert-print-contact > div, .expert-print-footer { grid-template-columns: 1fr; gap: 2mm; }
}

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

@media print {
    body.portal-page { background: #fff !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .no-print { display: none !important; }
    .expert-print-page { min-height: auto; padding: 0; }
    .expert-print-sheet { width: auto; max-width: none; margin: 0; padding: 0; box-shadow: none; }
    .expert-print-document-header, .expert-print-identity, .expert-print-section > h2, .expert-print-section-title, .expert-print-footer { break-inside: avoid; page-break-inside: avoid; }
    .expert-print-section { break-before: auto; page-break-before: auto; }
    a { color: inherit !important; }
}
