/*
 * YPA - Area Trainer, mobile-first.
 * Intentionally follows YPA's existing visual language:
 * #f5f6f8 app background, white tiles, #333 text, 14px radii.
 * No global page-width overrides or JavaScript dependencies.
 */
.ypa-trainer,
.ypa-trainer-access {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    color: #333333;
    background: #f5f6f8;
}

.ypa-trainer,
.ypa-trainer * ,
.ypa-trainer-access,
.ypa-trainer-access * {
    box-sizing: border-box;
}

.ypa-trainer-hero {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #ffffff;
    color: #333333;
    box-shadow: none;
}

.ypa-trainer-hero-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    border: 0;
    background: #333333;
    color: #ffffff;
    font-size: 19px;
}

.ypa-trainer-hero-copy,
.ypa-trainer-person-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.ypa-trainer-eyebrow {
    display: block;
    font-size: 9px;
    line-height: 1.4;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #737983;
}

.ypa-trainer-hero h1 {
    margin: 2px 0 3px;
    color: #333333;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
}

.ypa-trainer-hero p {
    margin: 0;
    color: #69717c;
    font-size: 11px;
    line-height: 1.35;
}

.ypa-trainer-welcome {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    row-gap: 3px;
    min-width: 0;
    margin-top: 10px;
    padding: 11px 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: none;
}

.ypa-trainer-person {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: #f0f0f0;
    color: #444444;
    font-size: 17px;
}

.ypa-trainer-person-copy .ypa-trainer-eyebrow {
    font-size: 9px;
}

.ypa-trainer-person-copy h2 {
    margin: 1px 0 2px;
    font-size: 14px;
    line-height: 1.25;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.ypa-trainer-person-copy p {
    margin: 0;
    color: #777777;
    font-size: 11px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.ypa-trainer-role {
    grid-column: 2;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    min-width: 0;
    margin: 2px 0 0;
    padding: 4px 8px;
    background: #f1f3f5;
    border-radius: 999px;
    color: #444444;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
}

.ypa-trainer-section-header {
    margin: 17px 0 10px;
}

.ypa-trainer-section-header h2 {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 3px;
    color: #333333;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.ypa-trainer-section-header p {
    margin: 0;
    color: #737983;
    font-size: 11px;
    line-height: 1.4;
}

/* Match Home's two-column mobile tile layout, even at 320px. */
.ypa-trainer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.ypa-trainer-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    min-height: 168px;
    margin: 0;
    padding: 12px 8px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #ffffff;
    text-align: center;
    box-shadow: none;
}

.ypa-trainer-feature-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    margin: 0 0 9px;
    border-radius: 11px;
    background: #f0f0f0;
    color: #333333;
    font-size: 19px;
}

.ypa-trainer-feature h3 {
    margin: 0 0 4px;
    color: #333333;
    font-size: 13px;
    line-height: 1.25;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.ypa-trainer-feature p {
    margin: 0 0 8px;
    color: #777777;
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.ypa-trainer-soon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin: auto 0 0;
    padding: 4px 6px;
    color: #777777;
    background: #f5f6f8;
    border-radius: 7px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.ypa-trainer-admin-notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 11px;
    padding: 11px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    color: #555555;
}

.ypa-trainer-admin-notice > i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: #555555;
}

.ypa-trainer-admin-notice p {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
}

.ypa-trainer-access {
    text-align: center;
    padding-top: 42px;
}

.ypa-trainer-access > i {
    color: #777777;
    font-size: 32px;
}

.ypa-trainer-access h2 {
    margin: 12px 0 7px;
    font-size: 17px;
}

.ypa-trainer-access p {
    margin: 0 0 14px;
    color: #777777;
    font-size: 12px;
    line-height: 1.5;
}

/* The original bottom bar contains icons only. Keep Trainer identical. */
.bottombar a.ypa-trainer-tab {
    display: flex;
    flex: 1 1 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 100%;
    gap: 0;
    padding: 6px 0;
    color: #999999;
    text-decoration: none;
}

.bottombar .ypa-trainer-tab-label {
    display: none;
}

.bottombar a.ypa-trainer-tab i {
    font-size: 20px;
}

/* Phone navigation must fit 4 or 5 tabs without scrolling. */
@media (max-width: 599.98px) {
    .bottombar {
        height: calc(52px + env(safe-area-inset-bottom, 0px));
        min-height: calc(52px + env(safe-area-inset-bottom, 0px));
        padding: 0 0 env(safe-area-inset-bottom, 0px);
    }

    .bottombar a {
        flex: 1 1 0;
        min-width: 0;
        padding: 5px 0;
    }

    .bottombar i,
    .bottombar a.ypa-trainer-tab i {
        font-size: 19px;
    }
}

/* Smaller phones: preserve two columns and prevent horizontal scrolling. */
@media (max-width: 360px) {
    .ypa-trainer,
    .ypa-trainer-access {
        padding-left: 8px;
        padding-right: 8px;
    }

    .ypa-trainer-hero,
    .ypa-trainer-welcome {
        padding: 10px;
    }

    .ypa-trainer-grid {
        gap: 8px;
    }

    .ypa-trainer-feature {
        padding: 10px 6px;
    }

    .ypa-trainer-feature h3 {
        font-size: 12px;
    }

    .ypa-trainer-feature p {
        font-size: 10px;
    }
}

/* Large screens: slightly more breathing room, without oversized cards. */
@media (min-width: 600px) {
    .ypa-trainer,
    .ypa-trainer-access {
        padding: 20px 18px 32px;
    }

    .ypa-trainer-grid {
        gap: 14px;
    }

    .ypa-trainer-feature {
        min-height: 154px;
        padding: 17px;
    }

    .ypa-trainer-welcome {
        grid-template-columns: 44px minmax(0, 1fr) auto;
    }

    .ypa-trainer-role {
        grid-column: 3;
        grid-row: 1;
        margin: 0;
    }
}

/* YPA exercise catalog — designed first for 320–430px phones. */
.ypa-trainer-feature-link { color: inherit; text-decoration: none; }
.ypa-trainer-feature-link:focus-visible,
.ypa-exercises button:focus-visible,
.ypa-exercises input:focus-visible,
.ypa-exercises select:focus-visible,
.ypa-exercises textarea:focus-visible { outline: 2px solid #525252; outline-offset: 2px; }
.ypa-trainer-feature-link:hover { color: inherit; }
.ypa-exercises,
.ypa-exercises *,
.ypa-ex-editor-form,
.ypa-ex-editor-form * { box-sizing: border-box; }
.ypa-exercises {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: 0;
    padding: 12px 10px calc(26px + env(safe-area-inset-bottom, 0px));
    color: #333;
    background: #f5f6f8;
    overflow: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.ypa-ex-head { display:flex; gap:10px; align-items:center; margin-bottom:12px; min-width:0; }
.ypa-ex-back { display:grid; flex:0 0 32px; width:32px; height:36px; place-items:center; border-radius:10px; color:#333; background:white; border:1px solid #e6e8eb; text-decoration:none; }
.ypa-ex-title { min-width:0; flex:1 1 auto; }
.ypa-ex-title h1 { margin:0; font-size:17px; font-weight:700; line-height:1.3; }
.ypa-ex-title p { margin:0; color:#717782; font-size:10px; line-height:1.35; }
.ypa-ex-primary { display:inline-flex; text-decoration: none; align-items:center; justify-content:center; flex:0 0 auto; gap:6px; border:0; border-radius:10px; background:#333; color:#fff; padding:10px 11px; min-height:38px; font-size:12px; font-weight:700; }
.ypa-ex-primary:disabled { opacity:.5; }
.ypa-ex-toolbar { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; margin-bottom:10px; }
.ypa-ex-search,.ypa-ex-selectwrap { position:relative; display:flex; align-items:center; min-width:0; height:42px; background:#fff; border:1px solid #e2e5e9; border-radius:11px; }
.ypa-ex-search > i,.ypa-ex-selectwrap > i { position:absolute; left:12px; pointer-events:none; font-size:13px; color:#8c9199; }
.ypa-ex-search input,.ypa-ex-selectwrap select { width:100%; min-width:0; height:100%; padding:0 12px 0 35px; border:0!important; outline:0; background:transparent; color:#333; font-size:13px; }
.ypa-ex-tabs { display:flex; gap:8px; margin:0 0 10px; }
.ypa-ex-tabs button { display:flex; align-items:center; justify-content:center; gap:6px; flex:1; padding:9px 6px; background:#fff; border:1px solid #e2e5e9; color:#747983; font-size:12px; font-weight:700; border-radius:10px; }
.ypa-ex-tabs button.active { background:#333; color:white; border-color:#333; }
.ypa-ex-meta { display:flex; justify-content:space-between; align-items:center; min-width:0; margin:2px 2px 9px; color:#6b717b; font-size:11px; }
.ypa-ex-list { display:flex; flex-direction:column; gap:8px; min-height:120px; }
.ypa-ex-card { display:flex; align-items:center; min-width:0; gap:9px; background:#fff; border:1px solid #e6e8eb; border-radius:12px; padding:9px; }
.ypa-ex-thumb { display:grid; place-items:center; width:60px; height:60px; flex:0 0 60px; overflow:hidden; border-radius:10px; background:#f2f3f5; color:#8b9199; font-size:22px; }
.ypa-ex-thumb img { width:100%; height:100%; object-fit:cover; }
.ypa-ex-details { flex:1 1 auto; min-width:0; }
.ypa-ex-details h3 { margin:0 0 3px; font-size:12px; font-weight:700; line-height:1.25; overflow-wrap:anywhere; }
.ypa-ex-details p { margin:0 0 3px; font-size:10px; color:#626c78; line-height:1.4; overflow-wrap:anywhere; }
.ypa-ex-details span { display:block; font-size:10px; color:#9499a2; line-height:1.2; overflow-wrap:anywhere; }
.ypa-ex-actions { display:flex; flex-direction:column; gap:6px; flex:0 0 auto; }
.ypa-ex-actions button,.ypa-ex-actions a { display:grid; place-items:center; width:32px; height:31px; border:1px solid #e2e5e9; color:#333; background:#f8f9fa; border-radius:9px; font-size:12px; }
.ypa-ex-actions button.danger { color:#b23d3d; background:#fdf3f3; border-color:#f9dede; }
.ypa-ex-pagination { display:flex; gap:10px; align-items:center; justify-content:space-between; padding:12px 0 8px; }
.ypa-ex-pagination button { display:inline-flex; gap:5px; align-items:center; justify-content:center; min-height:35px; padding:7px 10px; background:white; color:#333; border:1px solid #e2e5e9; border-radius:9px; font-size:11px; font-weight:700; }
.ypa-ex-pagination button:disabled { opacity:.4; }
.ypa-ex-pagination span { color:#6d7480; font-size:11px; }
.ypa-ex-empty { display:flex; min-height:156px; flex-direction:column; align-items:center; justify-content:center; gap:7px; padding:20px 14px; background:#fff; border:1px solid #e4e7ea; border-radius:12px; color:#727986; text-align:center; font-size:11px; }
.ypa-ex-empty > i { font-size:23px; }
.ypa-ex-empty strong { color:#333; font-size:13px; }
.ypa-ex-feedback { position:sticky; bottom:6px; z-index:5; padding:11px 13px; border-radius:10px; color:white; background:#313c35; font-size:12px; box-shadow:0 5px 18px #0002; }
.ypa-ex-feedback.is-error { background:#a33e3e; }

/* The editor is a normal, full SPA page. No overlay, modal or body scroll lock. */
.ypa-ex-feedback[hidden], .ypa-ex-editor-status[hidden], .ypa-ex-editor-form[hidden] { display:none !important; }
.ypa-ex-editor-status { display:flex; align-items:center; gap:9px; padding:25px 15px; background:#fff; border:1px solid #e6e8eb; border-radius:12px; font-size:12px; color:#66707c; }
.ypa-ex-editor-form { display:block; min-width:0; width:100%; padding:0; margin:0; }
.ypa-ex-editor-fields { display:flex; flex-direction:column; gap:14px; min-width:0; width:100%; padding:15px 12px 19px; border:1px solid #e6e8eb; border-radius:12px; background:#fff; }
.ypa-ex-editor-actions { display:flex; z-index:3; bottom:0; align-items:center; justify-content:space-between; gap:10px; margin-top:10px; padding:12px 4px calc(12px + env(safe-area-inset-bottom,0px)); background:#f5f6f8; }
.ypa-ex-editor-actions > a, .ypa-ex-editor-actions > button { text-decoration:none; flex:1; text-align:center; white-space:nowrap; }
.ypa-ex-editor-actions > button { flex:1.3; }
.ypa-ex-secondary { display:inline-flex; align-items:center; justify-content:center; min-height:40px; border:1px solid #dee1e5; background:white; color:#333; padding:9px 14px; border-radius:10px; font-size:12px; font-weight:700; }
.ypa-ex-editor-page .ypa-ex-feedback { margin:0 0 10px; }
.ypa-ex-actions a { text-decoration:none; }
.ypa-ex-primary:visited, .ypa-ex-actions a:visited { color:inherit; }
.ypa-ex-primary:visited { color:#fff; }
.ypa-ex-field { display:flex; flex-direction:column; align-items:stretch; min-width:0; gap:4px; margin:0; color:#333; font-size:12px; font-weight:700; }
.ypa-ex-field > span b { color:#be4747; }
.ypa-ex-field small { display:block; font-size:10px; font-weight:400; color:#858b95; line-height:1.35; }
.ypa-ex-field input,.ypa-ex-field textarea,.ypa-ex-field select { width:100%; min-width:0; min-height:40px; padding:10px; font-family:inherit; border:1px solid #dfe3e8; border-radius:9px; background:#fff; color:#333; font-size:12px; font-weight:400; }
.ypa-ex-field textarea { resize:vertical; min-height:108px; }
.ypa-ex-fields2 { display:grid; grid-template-columns:1fr 1fr; min-width:0; gap:9px; }
.ypa-ex-upload { display:inline-flex; align-items:center; align-self:flex-start; justify-content:center; gap:7px; padding:11px; border:1px dashed #cbd0d7; border-radius:10px; background:#f7f8f9; color:#333; font-size:11px; cursor:pointer; }
.ypa-ex-upload input { position:absolute; width:1px; height:1px; opacity:0; overflow:hidden; }
.ypa-ex-pictures { display:flex; flex-wrap:wrap; gap:8px; }
.ypa-ex-picture { position:relative; display:grid; place-items:center; width:66px; height:66px; border-radius:9px; overflow:hidden; background:#f0f2f4; }
.ypa-ex-picture img { width:100%; height:100%; object-fit:cover; }
.ypa-ex-picture button { position:absolute; right:3px; top:3px; width:22px; height:22px; background:#333; color:white; border:0; border-radius:7px; font-size:10px; }
@media (max-width:355px) {
    .ypa-exercises { padding-left:7px; padding-right:7px; }
    .ypa-ex-card { gap:7px; padding:7px; }
    .ypa-ex-thumb { width:52px; height:52px; flex-basis:52px; }
    .ypa-ex-actions button { width:29px; height:29px; }
    .ypa-ex-primary span { display:none; }
    .ypa-ex-title h1 { font-size:16px; }
}
@media (min-width:600px) {
    .ypa-exercises { max-width:780px; margin-inline:auto; padding:20px; }
    .ypa-ex-toolbar { grid-template-columns:minmax(0,1fr) 220px; }
    .ypa-ex-card { padding:11px; }
    .ypa-ex-thumb { width:72px; height:72px; flex-basis:72px; }
    .ypa-ex-details h3 { font-size:14px; }
    .ypa-ex-actions { flex-direction:row; }
    .ypa-ex-editor-fields { padding:18px; }
    .ypa-ex-editor-actions { justify-content:flex-end; }
    .ypa-ex-editor-actions > a, .ypa-ex-editor-actions > button { flex:0 1 auto; }
}

@media (max-width:355px) {
    .ypa-ex-editor-fields { padding:12px 9px 16px; }
    .ypa-ex-editor-actions { gap:7px; }
    .ypa-ex-editor-actions > a, .ypa-ex-editor-actions > button { padding-inline:8px; font-size:11px; }
}
