/* 精通頁：進度清單與操作詳情使用同一份即時精通模型。 */
#mastery-detail[hidden] { display: none !important; }
#mastery-detail { display: none; }
#m-masterysheet { display: none; }

@media (min-width: 768px) {
    body[data-mpage="char"][data-mastery-view="1"] #game-screen { grid-template-columns: 263px minmax(0, 1fr) 350px; }
    body[data-mpage="char"][data-mastery-view="1"] #col-center { display: none !important; }
    body[data-mpage="char"][data-mastery-view="1"] #col-right {
        grid-column: 2 / 4; grid-row: 2; display: grid !important;
        grid-template-columns: minmax(0, 1fr) 350px;
        grid-template-rows: 54px minmax(0, 1fr);
        width: auto !important; min-width: 0; min-height: 0; gap: 0;
    }
    body[data-mpage="char"][data-mastery-view="1"] #tabbar {
        grid-column: 2; grid-row: 1; min-width: 0; border-left: 1px solid var(--ed-line);
    }
    body[data-mpage="char"][data-mastery-view="1"] #col-right > .panel:last-child {
        grid-column: 1; grid-row: 1 / 3; min-width: 0; min-height: 0;
        border: 0; background: #152123;
    }
    body[data-mpage="char"][data-mastery-view="1"] #mastery-detail {
        grid-column: 2; grid-row: 2; display: block; min-width: 0; min-height: 0;
        overflow-y: auto; border-left: 1px solid var(--ed-line);
    }
}

body[data-mastery-view="1"] #tab-mastery:not(.hidden) {
    width: 100%; height: 100%; min-height: 0; padding: 0;
    background: #152123; overflow: hidden;
}
body[data-mastery-view="1"] #tab-mastery .scroll-fill {
    flex: 1 1 0%; min-height: 0; width: 100%;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: #53635d #152123;
}
.cm-hero {
    position: relative; min-height: 148px; padding: 27px 31px;
    border-bottom: 1px solid var(--ed-line);
    background: linear-gradient(90deg,#172326 0%,#172326ed 48%,#17232670),
        url('../assets/background/background.png') center 46% / cover;
}
.cm-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 65px #0d171a9e; }
.cm-hero > * { position: relative; z-index: 1; }
.cm-hero > span, .cm-section-head > div > span, .cm-detail-head > span {
    color: var(--ed-gold-light); font-size: 10px; font-weight: 800; letter-spacing: .15em;
}
.cm-hero h2 { margin: 10px 0 6px; color: var(--ed-text); font-size: 29px; letter-spacing: .08em; }
.cm-hero p { margin: 0; color: #b6c7bb; font-size: 12px; }
.cm-hero > small {
    position: absolute; top: 28px; right: 30px; padding: 7px 10px;
    border: 1px solid #81745c; background: #222b29b8;
    color: var(--ed-gold-light); font-size: 10px; font-weight: 700; letter-spacing: .08em;
}
.cm-content { padding: 22px 31px 28px; }
.cm-section-head {
    display: flex; align-items: end; justify-content: space-between; gap: 10px;
    padding-bottom: 14px; border-bottom: 1px solid var(--ed-line);
}
.cm-section-head h3 { margin: 7px 0 0; color: var(--ed-text); font-size: 18px; }
.cm-section-head > small { color: var(--ed-quiet); font-size: 10px; text-align: right; }
.cm-summary {
    display: grid; grid-template-columns: repeat(3,minmax(0,1fr));
    margin: 16px 0 14px; border: 1px solid var(--ed-line); background: #1b2929;
}
.cm-summary > div { min-width: 0; padding: 11px 14px; border-right: 1px solid var(--ed-line-soft); }
.cm-summary > div:last-child { border: 0; }
.cm-summary small { display: block; color: var(--ed-quiet); font-size: 10px; }
.cm-summary strong { display: block; margin-top: 6px; color: var(--ed-text); font-size: 16px; font-variant-numeric: tabular-nums; }
.cm-summary strong small { display: inline; font-size: 10px; font-weight: 400; }
.cm-summary strong.green { color: #a4d2ad; }
.cm-summary strong.gold { color: var(--ed-gold-light); }
.cm-intro {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 14px; padding: 12px 14px;
    border-left: 2px solid var(--ed-gold); background: #29342e;
    color: #cbd6ca; font-size: 11px; line-height: 1.55;
}
.cm-intro > span { color: var(--ed-gold-light); font-size: 21px; }
.cm-intro p { margin: 0; }
.cm-intro b { color: var(--ed-gold-light); }
.cm-unavailable { margin-top: 18px; padding: 30px 16px; color: var(--ed-muted); text-align: center; font-size: 12px; }
.cm-list { display: grid; gap: 9px; }
.cm-card {
    display: block; width: 100%; min-height: 151px; padding: 15px 17px;
    border: 1px solid var(--ed-line); border-radius: 0; background: #202c2c;
    color: var(--ed-text); text-align: left; cursor: pointer;
}
.cm-card:hover { background: #263633; }
.cm-card:focus-visible { outline: 2px solid var(--ed-gold-light); outline-offset: -2px; }
.cm-card.selected { border-color: #ac986b; box-shadow: inset 3px 0 0 #c4ab77; background: #2b342e; }
.cm-card.on { border-color: #668775; }
.cm-card-head, .cm-card-effect, .cm-card-foot { display: flex; align-items: center; }
.cm-card-head { gap: 12px; }
.cm-sigil {
    display: grid; place-items: center; width: 43px; height: 43px; flex: 0 0 43px;
    border: 1px solid #81775d; background: #26302b;
    color: var(--ed-gold-light); font-size: 23px; line-height: 1;
}
.cm-card-name { min-width: 0; flex: 1; }
.cm-card-name strong { display: block; color: #eee1c1; font-size: 15px; }
.cm-card-name small { display: block; margin-top: 4px; color: var(--ed-muted); font-size: 10px; }
.cm-card-head > b { align-self: flex-start; color: var(--ed-gold-light); font-size: 12px; white-space: nowrap; }
.cm-pips { display: flex; gap: 4px; margin: 13px 0 9px; }
.cm-pips i { height: 4px; flex: 1; background: #485850; }
.cm-pips i.filled { background: #b9aa79; }
.cm-card-effect, .cm-card-foot { justify-content: space-between; gap: 8px; font-size: 11px; }
.cm-card-effect { color: var(--ed-muted); }
.cm-card-effect strong { color: var(--ed-gold-light); font-size: 12px; }
.cm-card-foot { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--ed-line-soft); color: var(--ed-quiet); }
.cm-card-foot small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.cm-card-foot b { font-size: 10px; white-space: nowrap; }
.cm-card-foot b.on { color: #a4d2ad; }
.cm-card-foot b.ready { color: var(--ed-gold-light); }
.cm-card-foot b.blocked { color: #d9998f; }

#mastery-detail {
    padding: 21px 20px 28px; background: var(--ed-surface);
    color: var(--ed-text); scrollbar-width: thin; scrollbar-color: #53635d var(--ed-surface);
}
.cm-detail-head { padding-bottom: 16px; border-bottom: 1px solid var(--ed-line); }
.cm-detail-head strong { display: block; margin-top: 8px; color: var(--ed-text); font-size: 18px; }
.cm-detail-head p { margin: 5px 0 0; color: var(--ed-muted); font-size: 11px; }
.cm-detail-identity { display: flex; align-items: center; gap: 12px; margin: 19px 0; }
.cm-detail-identity strong { display: block; font-size: 17px; }
.cm-detail-identity small { display: block; margin-top: 5px; color: var(--ed-muted); font-size: 10px; }
.cm-detail-group { margin-top: 20px; }
.cm-detail-group h3 { margin: 0 0 11px; color: var(--ed-gold-light); font-size: 12px; }
.cm-ladder { display: flex; gap: 5px; }
.cm-ladder span { flex: 1; padding: 8px 0; border: 1px solid var(--ed-line); color: #9db0a4; text-align: center; font-size: 10px; }
.cm-ladder span.current { border-color: #b79e70; background: #393b30; color: #f0d9a9; }
.cm-ladder span.past { border-color: #708676; color: #b8d4bc; }
.cm-detail-row { display: flex; justify-content: space-between; align-items: start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ed-line-soft); font-size: 11px; }
.cm-detail-row span { color: var(--ed-muted); overflow-wrap: anywhere; }
.cm-detail-row b { color: var(--ed-text); text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.cm-detail-row b.good { color: #a4d2ad; }
.cm-detail-row b.gold { color: var(--ed-gold-light); }
.cm-detail-row b.missing { color: #d9998f; }
.cm-actions { display: grid; gap: 8px; margin-top: 20px; }
.cm-action { min-height: 42px; padding: 9px; border: 1px solid #a69167; border-radius: 0; background: #403d2e; color: #eed5a3; font-size: 12px; font-weight: 800; cursor: pointer; }
.cm-action.secondary { border-color: #6c806d; background: #26382d; color: #c7e4c9; }
.cm-action:disabled { border-color: #536159; background: #27312c; color: #8da096; cursor: default; }
.cm-actions small { color: var(--ed-quiet); font-size: 10px; line-height: 1.45; }

@media (min-width: 768px) and (max-width: 1080px) {
    body[data-mpage="char"][data-mastery-view="1"] #game-screen { grid-template-columns: 205px minmax(0,1fr) 278px; }
    body[data-mpage="char"][data-mastery-view="1"] #col-right { grid-template-columns: minmax(0,1fr) 278px; }
    .cm-content { padding-left: 18px; padding-right: 18px; }
    #mastery-detail { padding-left: 15px; padding-right: 15px; }
    .cm-hero > small { right: 15px; }
}

@media (max-width: 767px) {
    body[data-mpage="char"][data-mastery-view="1"] #st-buffs { display: none !important; }
    body[data-mpage="char"][data-mastery-view="1"] #col-right { display: flex; flex-direction: column; min-height: 0; }
    body[data-mpage="char"][data-mastery-view="1"] #tabbar { order: 0; flex: 0 0 47px; }
    body[data-mpage="char"][data-mastery-view="1"] #col-right > .panel:last-child { order: 1; flex: 1 1 auto; min-height: 0; }
    body[data-mpage="char"][data-mastery-view="1"] #mastery-detail { display: none !important; }
    .cm-hero { min-height: 68px; padding: 14px 15px; background: #1a2729; }
    .cm-hero > span, .cm-hero p, .cm-hero > small { display: none; }
    .cm-hero h2 { margin: 2px 0 0; font-size: 20px; }
    .cm-content { padding: 14px; }
    .cm-section-head h3 { font-size: 15px; }
    .cm-section-head > small { font-size: 9px; }
    .cm-summary { margin: 12px 0; }
    .cm-summary > div { padding: 9px; }
    .cm-summary strong { font-size: 13px; }
    .cm-summary small { font-size: 9px; }
    .cm-intro { margin-bottom: 12px; padding: 10px; font-size: 10px; }
    .cm-intro > span { font-size: 18px; }
    .cm-card { min-height: 132px; padding: 12px; }
    .cm-card-head { gap: 9px; }
    .cm-sigil { width: 38px; height: 38px; flex-basis: 38px; font-size: 20px; }
    .cm-card-name strong { font-size: 13px; }
    .cm-card-name small { font-size: 9px; }
    .cm-card-head > b { font-size: 11px; }
    .cm-pips { margin: 10px 0 7px; }
    .cm-card-effect, .cm-card-foot { font-size: 10px; }

    #m-masterysheet {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 72;
        max-height: calc(var(--app-h, 100dvh) - 142px);
        flex-direction: column; border-top: 1px solid #bca574;
        background: var(--ed-surface); box-shadow: 0 -20px 50px #0009;
        transform: translateY(105%); transition: transform .2s;
    }
    body[data-msheet="mastery"] #m-masterysheet { display: flex; transform: translateY(0); }
    #m-masterysheet-head {
        flex: 0 0 49px; display: flex; align-items: center; justify-content: space-between;
        padding: 0 15px; border-bottom: 1px solid var(--ed-line);
        color: var(--ed-gold-light); font-size: 11px; font-weight: 800; letter-spacing: .08em;
    }
    #m-masterysheet-head button { width: 36px; height: 36px; border: 0; background: none; color: var(--ed-muted); font-size: 20px; }
    #m-masterysheet-body { min-height: 0; overflow-y: auto; padding: 15px 16px 22px; color: var(--ed-text); }
    #m-masterysheet-body .cm-detail-head { padding-bottom: 10px; }
    #m-masterysheet-body .cm-detail-head > span, #m-masterysheet-body .cm-detail-head p { display: none; }
    #m-masterysheet-body .cm-detail-head strong { margin: 0; color: var(--ed-gold-light); font-size: 16px; }
    #m-masterysheet-body .cm-detail-identity { margin: 12px 0; }
    #m-masterysheet-body .cm-detail-group { margin-top: 15px; }
    #m-masterysheet-body .cm-actions { margin-top: 17px; }
    #m-masterysheet-body .cm-action { min-height: 44px; }
}
