/* =========================================================
   พื้นที่สมาชิก (ตามดีไซน์ Figma): หัวเว็บแอป, ภาพรวม, บันทึกเทรด, เรียนรู้, เครื่องมือ
   ========================================================= */
body:has(.mh) { background: #F3F6F4; }
.member-main { max-width: 76rem; }

/* ---------- หัวเว็บสมาชิก ---------- */
.mh { background: rgba(255, 255, 255, .92); }
.mh-inner { height: 4.75rem; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.mh .brand { flex: none; text-decoration: none; }
.mh-nav { display: flex; align-items: center; gap: .35rem; }
.mh-nav a {
    padding: .55rem .9rem; border-radius: 10px; color: #475569; font-family: var(--font-head); font-size: .9rem; font-weight: 600;
    text-decoration: none; transition: color .15s, background .15s;
}
.mh-nav a:hover { color: #065F46; background: #F1F5F3; }
.mh-nav a.on { color: #065F46; font-weight: 700; }
.mh-actions { display: flex; align-items: center; gap: .6rem; }
.mh-install {
    display: inline-flex; align-items: center; gap: .5rem; height: 2.6rem; padding: 0 1rem; border-radius: 12px;
    border: 1px solid #A7F3D0; background: #ECFDF5; color: #065F46; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.mh-install[hidden] { display: none; }
.mh-install:hover { background: #D1FAE5; }
.mh-install svg, .mh-icon svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.mh-pop { position: relative; }
.mh-pop > summary { list-style: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mh-pop > summary::-webkit-details-marker { display: none; }
.mh-icon { position: relative; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 12px; color: #475569; }
.mh-icon:hover, .mh-pop[open] > .mh-icon { background: #F1F5F3; color: #065F46; }
.mh-badge {
    position: absolute; top: .3rem; right: .25rem; min-width: 1.05rem; height: 1.05rem; padding: 0 .25rem; border-radius: 999px;
    display: grid; place-items: center; background: #E11D48; color: #fff; font-size: .62rem; font-weight: 800; box-shadow: 0 0 0 2px #fff;
}
.mh-avatar {
    width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 12px;
    background: #D1FAE5; color: #065F46; font-weight: 800; font-size: .9rem;
}
.mh-pop[open] > .mh-avatar { box-shadow: 0 0 0 3px #A7F3D0; }
.mh-panel {
    position: absolute; right: 0; top: calc(100% + .6rem); z-index: 70; width: min(22rem, calc(100vw - 2rem));
    background: #fff; color: #172420; border: 1px solid #E2E8F0; border-radius: 18px; padding: .75rem;
    box-shadow: 0 20px 50px rgba(15, 50, 42, .16); animation: mh-in .16s ease-out;
}
@keyframes mh-in { from { opacity: 0; transform: translateY(-4px); } }
.mh-panel-title { margin: .25rem .4rem .6rem; font-weight: 700; font-size: .95rem; }
.mh-empty { margin: .25rem .4rem .75rem; font-size: .85rem; color: #64748B; line-height: 1.6; }
.mh-notes { list-style: none; margin: 0; padding: 0; max-height: min(24rem, 60vh); overflow-y: auto; }
.mh-note > a, .mh-note > div {
    display: flex; gap: .65rem; padding: .65rem .5rem; border-radius: 12px; color: inherit; text-decoration: none;
}
.mh-note > a:hover { background: #F6F8F7; }
.mh-note-dot { flex: none; width: .55rem; height: .55rem; margin-top: .45rem; border-radius: 50%; background: #CBD5E1; }
.mh-note.tone-bad .mh-note-dot { background: #E11D48; }
.mh-note.tone-warn .mh-note-dot { background: #F59E0B; }
.mh-note.tone-info .mh-note-dot { background: #10B981; }
.mh-note:not(.is-new) .mh-note-dot { opacity: .35; }
.mh-note-body { min-width: 0; display: grid; gap: .15rem; }
.mh-note-body b { font-size: .85rem; }
.mh-note-body span { font-size: .8rem; color: #475569; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.mh-note-body small { font-size: .7rem; color: #94A3B8; }
.mh-seen { display: none; }
.mh-panel-foot { display: block; margin-top: .4rem; padding: .6rem .5rem 0; border-top: 1px solid #F1F5F9; font-size: .82rem; font-weight: 700; color: #047857; text-decoration: none; }
.mh-user-panel { width: 16rem; display: grid; gap: .1rem; }
.mh-user-name { margin: .2rem .5rem .5rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-user-panel > a, .mh-logout {
    display: block; width: 100%; text-align: left; padding: .6rem .5rem; border-radius: 10px; border: 0; background: none;
    color: #334155; font: inherit; font-size: .88rem; text-decoration: none; cursor: pointer;
}
.mh-user-panel > a:hover, .mh-logout:hover { background: #F6F8F7; color: #065F46; }
.mh-user-panel .lang-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: .2rem; margin: .4rem 0; padding: .2rem; border-radius: 10px; background: #F1F5F3; }
.mh-user-panel .lang-switch a { text-align: center; padding: .4rem; border-radius: 8px; font-size: .8rem; color: #475569; text-decoration: none; }
.mh-user-panel .lang-switch a[aria-current="true"] { background: #fff; color: #065F46; font-weight: 700; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.mh-user-panel form { margin: 0; border-top: 1px solid #F1F5F9; padding-top: .2rem; }
.mh-logout { color: #BE123C; }

.member-foot { padding: 1.5rem 0 2rem; font-size: .75rem; color: #94A3B8; }
.member-foot p { margin: .2rem 0; }
.member-foot a { color: inherit; }

/* ---------- หัวหน้าแต่ละหน้า ---------- */
.mp-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1.5rem; }
.mp-kicker, .hub-kicker { margin: 0 0 .35rem; color: #047857; font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.mp-head h1, .journal-head h1 { margin: 0; font-family: var(--font-head); font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 700; color: #10251F; letter-spacing: -.02em; }
.mp-desc { margin: .4rem 0 0; font-size: .88rem; color: #64748B; }
.mp-head .button { border-radius: 12px; }

/* ---------- การ์ดกลาง ---------- */
.hub-card, .me-card, .j-chart, .j-insights, .journal-section, .journal-filters, .jtabs {
    background: #fff; border: 1px solid rgba(226, 232, 240, .85); border-radius: 22px; box-shadow: 0 6px 24px rgba(20, 55, 46, .04);
}
.hub-card { padding: 1.4rem 1.5rem; display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.hub-card h2 { margin: 0; font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; color: #10251F; }
.hub-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.hub-link { align-self: flex-start; margin-top: auto; color: #047857; font-size: .85rem; font-weight: 700; text-decoration: none; }
.hub-link::after { content: " →"; }
.hub-link:hover { color: #065F46; text-decoration: underline; }

/* ---------- ภาพรวม: หัว ---------- */
.hub-hero {
    display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    margin: .25rem 0 1rem; padding: 1.75rem 2rem; border-radius: 28px; color: #fff;
    background: radial-gradient(120% 140% at 100% 0%, #14513F 0%, transparent 55%), linear-gradient(135deg, #092B25, #0C302A);
}
.hub-me { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.hub-avatar { flex: none; width: 3.5rem; height: 3.5rem; display: grid; place-items: center; border-radius: 16px; background: #34D399; color: #092B25; font-weight: 800; font-size: 1.3rem; }
.hub-hi { margin: 0; font-size: .8rem; color: #6EE7B7; }
.hub-hero h1 { margin: .1rem 0 .2rem; font-family: var(--font-head); font-size: clamp(1.4rem, 3vw, 1.75rem); color: #fff; overflow-wrap: anywhere; }
.hub-since { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .75rem; color: rgba(255, 255, 255, .55); }
.hub-pro { padding: .15rem .55rem; border-radius: 999px; background: rgba(232, 111, 62, .2); color: #FDBA74; font-weight: 700; text-decoration: none; }
.hub-today { flex: 0 1 28rem; padding: 1rem 1.15rem; border-radius: 18px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); }
.hub-today-title { margin: 0 0 .6rem; font-size: .78rem; font-weight: 700; color: #6EE7B7; }
.hub-today-title small { margin-left: .35rem; font-weight: 500; color: rgba(255, 255, 255, .45); }
.hub-today dl { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.hub-today dt { font-size: .68rem; color: rgba(255, 255, 255, .55); }
.hub-today dd { margin: .2rem 0 0; font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; color: #fff; white-space: nowrap; }
.hub-today dd.pos { color: #6EE7B7; }
.hub-today dd.neg { color: #FDA4AF; }
.hub-today dd a { color: #6EE7B7; font-size: .9rem; }
.hub-today .hub-stop { color: #FDA4AF; font-size: .9rem; white-space: normal; }

.hub-plan {
    display: flex; align-items: center; gap: 1rem; margin: 0 0 1rem; padding: 1rem 1.25rem; border-radius: 18px;
    background: #FFF7ED; border: 1px solid #FED7AA;
}
.hub-plan > div { flex: 1; min-width: 0; display: grid; gap: .15rem; }
.hub-plan b { font-size: .92rem; color: #7C2D12; }
.hub-plan small { font-size: .78rem; color: #C2410C; }
.hub-plan-tag { flex: none; padding: .3rem .55rem; border-radius: 8px; background: #E86F3E; color: #fff; font-size: .68rem; font-weight: 800; letter-spacing: .05em; }
.hub-plan .button { flex: none; border-radius: 12px; }

.hub-insight {
    display: flex; align-items: flex-start; gap: 1rem; margin: 0 0 1rem; padding: 1.15rem 1.35rem; border-radius: 22px;
    background: #fff; border: 1px solid rgba(226, 232, 240, .85); box-shadow: 0 6px 24px rgba(20, 55, 46, .04);
}
.hub-insight > div { flex: 1; min-width: 0; }
.hub-insight-ico { flex: none; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 12px; background: #FFF1F2; color: #E11D48; }
.hub-insight.tone-good .hub-insight-ico { background: #ECFDF5; color: #059669; }
.hub-insight-ico svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.hub-insight-text { margin: 0; font-weight: 700; font-size: .98rem; color: #10251F; line-height: 1.55; }
.hub-insight-tip { margin: .3rem 0 0; font-size: .85rem; color: #64748B; }
.hub-insight .hub-link { align-self: center; margin: 0; white-space: nowrap; }

.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.hub-progress-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; font-weight: 700; }
.hub-progress-head small { font-weight: 500; color: #94A3B8; }
.hub-meter { height: .55rem; border-radius: 999px; background: #EEF2F0; overflow: hidden; }
.hub-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #059669, #10B981); }
.hub-next { display: flex; align-items: center; gap: .8rem; padding: .8rem; border-radius: 14px; background: #F6F8F7; border: 1px solid #EEF2F0; color: inherit; text-decoration: none; }
.hub-next:hover { border-color: #A7F3D0; background: #F0FDF4; }
.hub-next-step { flex: none; width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 10px; background: #065F46; color: #fff; font-weight: 800; }
.hub-next b { display: block; font-size: .9rem; line-height: 1.4; }
.hub-next small { font-size: .74rem; color: #64748B; }

.hub-stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-radius: 14px; border: 1px solid #EEF2F0; overflow: hidden; }
.hub-stats > div { padding: .8rem .9rem; border-right: 1px solid #EEF2F0; border-bottom: 1px solid #EEF2F0; min-width: 0; }
.hub-stats > div:nth-child(3n) { border-right: 0; }
.hub-stats > div:nth-last-child(-n+3) { border-bottom: 0; }
.hub-stats dt { font-size: .7rem; color: #94A3B8; }
.hub-stats dd { margin: .25rem 0 0; font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; color: #10251F; white-space: nowrap; }
.hub-stats dd.pos, .j-mini dd.pos { color: #059669; }
.hub-stats dd.neg, .j-mini dd.neg { color: #E11D48; }
.hub-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.hub-actions .button { border-radius: 12px; }
.hub-accts { display: flex; flex-wrap: wrap; gap: .4rem; text-decoration: none; }
.hub-accts .acct-chip { pointer-events: none; }

.hub-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.hub-tiles a, .mt-tile, .ml-topics a {
    display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; padding: .9rem; border-radius: 16px;
    background: #F6F8F7; border: 1px solid #EEF2F0; color: #10251F; text-decoration: none; transition: border-color .15s, transform .15s;
}
.hub-tiles a:hover, .mt-tile:hover, .ml-topics a:hover { border-color: #A7F3D0; transform: translateY(-2px); }
.hub-tiles b, .mt-tile b { font-size: .88rem; }
.hub-tile-ico { width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: 11px; background: #fff; color: #047857; box-shadow: 0 1px 3px rgba(15, 50, 42, .08); }
.hub-tile-ico svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- กราฟกำไรสะสม ---------- */
.eq-plot { position: relative; }
.eq .equity-chart { height: 13rem; border: 0; border-radius: 0; background: none; overflow: visible; }
.eq-compact .equity-chart { height: 10rem; }
.eq-area { opacity: .14; }
.eq.is-pos .eq-area { fill: #059669; }
.eq.is-neg .eq-area { fill: #E11D48; }
.eq .equity-zero { stroke: #CBD5E1; }
.eq-ylab { position: absolute; left: 0; transform: translateY(-50%); padding: 0 .3rem; border-radius: 6px; background: rgba(255, 255, 255, .85); font-size: .66rem; font-weight: 600; color: #94A3B8; pointer-events: none; }
.eq-ylab-zero { color: #64748B; }
.eq-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: #CBD5E1; pointer-events: none; }
.eq-dot { position: absolute; width: .7rem; height: .7rem; margin: -.35rem 0 0 -.35rem; border-radius: 50%; background: #fff; border: 2px solid #059669; pointer-events: none; }
.eq.is-neg .eq-dot { border-color: #E11D48; }
.eq-tip {
    position: absolute; top: -.4rem; transform: translate(-50%, -100%); padding: .3rem .55rem; border-radius: 8px;
    background: #0F172A; color: #fff; font-size: .72rem; font-weight: 700; white-space: nowrap; pointer-events: none;
}
.eq-tip.is-neg { color: #FDA4AF; }
.eq-cursor[hidden], .eq-dot[hidden], .eq-tip[hidden] { display: none; }
.eq .equity-axis { align-items: center; font-size: .72rem; color: #94A3B8; }
.eq-last { font-weight: 800; font-size: .8rem; }
.eq-last.pos { color: #059669; }
.eq-last.neg { color: #E11D48; }
.eq[data-eq] { touch-action: pan-y; cursor: crosshair; }

/* ---------- บันทึกเทรด ---------- */
.journal-head { align-items: flex-end; }
.journal-head .mp-desc { margin-bottom: .2rem; }
.journal-filters { padding: .6rem .7rem; border-radius: 18px; }
.journal-filters .chip { border-radius: 10px; }
.journal-filters .chip.on { background: #065F46; border-color: #065F46; color: #fff; }
.jtabs { border-radius: 18px; padding: .35rem; }
.jtab { border-radius: 13px; }
.jtab.on { background: #0C302A; color: #fff; }
.journal-section { padding: 1.25rem 1.4rem; }
.journal-section > h2, .j-chart h2 { font-family: var(--font-head); font-size: 1.15rem; }
.journal-top { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; margin-bottom: 1rem; }
.journal-top .journal-section { margin: 0; }
.j-kpi { border-radius: 22px; overflow: hidden; background: #fff; border: 1px solid rgba(226, 232, 240, .85); box-shadow: 0 6px 24px rgba(20, 55, 46, .04); }
.j-kpi-main { padding: 1.35rem 1.4rem 1.5rem; background: linear-gradient(135deg, #092B25, #0C302A); color: rgba(255, 255, 255, .6); font-size: .78rem; }
.j-kpi-main b { display: block; margin-top: .35rem; font-family: var(--font-head); font-size: clamp(1.9rem, 4vw, 2.4rem); color: #fff; }
.j-kpi-main b.pos { color: #6EE7B7; }
.j-kpi-main b.neg { color: #FDA4AF; }
.j-kpi-grid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.j-kpi-grid > div { padding: .95rem 1.1rem; border-right: 1px solid #EEF2F0; border-bottom: 1px solid #EEF2F0; min-width: 0; }
.j-kpi-grid > div:nth-child(3n) { border-right: 0; }
.j-kpi-grid > div:nth-last-child(-n+3) { border-bottom: 0; }
.j-kpi-grid dt, .j-mini dt { font-size: .7rem; color: #94A3B8; }
.j-kpi-grid dd { margin: .3rem 0 0; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.j-kpi-grid dd.pos { color: #059669; }
.j-kpi-grid dd.neg { color: #E11D48; }
.j-mini { margin: 0 0 .5rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.j-mini > div { padding: 1.1rem 1.25rem; border-radius: 20px; background: #fff; border: 1px solid rgba(226, 232, 240, .85); box-shadow: 0 6px 24px rgba(20, 55, 46, .04); min-width: 0; }
.j-mini dd { margin: .45rem 0 0; font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.j-exp { margin: 0 0 1rem .25rem; }

.j-insights { margin: 0 0 1rem; padding: 1.1rem 1.35rem; }
.j-insights h2 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .75rem; font-family: var(--font-head); font-size: 1.05rem; }
.j-insights h2 svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: #047857; stroke-width: 1.9; stroke-linecap: round; }
.j-insights ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.j-insights li { display: grid; gap: .15rem; padding: .75rem .9rem .75rem 1rem; border-radius: 14px; background: #FFF5F6; border-left: 3px solid #E11D48; }
.j-insights li.tone-good { background: #F0FDF4; border-left-color: #059669; }
.j-insights b { font-size: .9rem; color: #10251F; line-height: 1.5; }
.j-insights span { font-size: .8rem; color: #64748B; }

.guard-card { padding: 1.15rem 1.35rem; margin-bottom: 1rem; border-radius: 22px; border-left-width: 4px; box-shadow: 0 6px 24px rgba(20, 55, 46, .04); }

/* ---------- เรียนรู้ ---------- */
.ml-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ml-side { display: grid; gap: 1rem; }
.ml-badge { flex: none; padding: .3rem .65rem; border-radius: 999px; background: #FFF7ED; color: #C2410C; font-size: .72rem; font-weight: 700; }
.ml-badge.is-done { background: #ECFDF5; color: #047857; }
.ml-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.ml-list a { display: flex; align-items: center; gap: .8rem; padding: .7rem .75rem; border-radius: 14px; border: 1px solid transparent; color: inherit; text-decoration: none; }
.ml-list a:hover { background: #F6F8F7; border-color: #EEF2F0; }
.ml-step { flex: none; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border-radius: 10px; background: #F1F5F3; color: #64748B; font-weight: 800; font-size: .85rem; }
.ml-list .is-done .ml-step { background: #D1FAE5; color: #047857; }
.ml-list .is-next a { background: #F0FDF4; border-color: #A7F3D0; }
.ml-list .is-next .ml-step { background: #065F46; color: #fff; }
.ml-title { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.ml-title b { font-size: .9rem; line-height: 1.45; font-weight: 600; }
.ml-title small { font-size: .72rem; color: #94A3B8; }
.ml-list .is-next .ml-title small { color: #047857; font-weight: 700; }
.ml-go { color: #CBD5E1; font-size: 1.3rem; line-height: 1; }
.ml-tutor { background: linear-gradient(160deg, #ECFDF5, #fff 60%); }
.ml-topics { display: grid; gap: .5rem; }
.ml-topics a { flex-direction: row; align-items: center; padding: .65rem .8rem; }
.ml-topics a b { flex: 1; font-size: .88rem; }

/* ---------- เครื่องมือ ---------- */
.mt-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.mt-calc .hm-calc { border: 1px solid rgba(226, 232, 240, .85); box-shadow: 0 6px 24px rgba(20, 55, 46, .05); border-radius: 22px; }
.mt-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.mt-tile { background: #fff; padding: 1.1rem; border-radius: 20px; }
.mt-tile small { font-size: .74rem; color: #64748B; line-height: 1.5; }
.mt-tile .hub-tile-ico { background: #ECFDF5; box-shadow: none; }

/* ---------- ตั้งค่าบัญชี ---------- */
.me-card { border-radius: 22px; padding: 1.35rem 1.5rem; }
.me-danger { border-radius: 18px; }

/* ---------- มือถือ ---------- */
@media (max-width: 1024px) {
    .mh-nav { display: none; }
    .ml-grid, .mt-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
    .mh-inner { height: 4rem; gap: .75rem; }
    .mh-install span { display: none; }
    .mh-install { width: 2.6rem; padding: 0; justify-content: center; }
    .mh-panel { position: fixed; left: .75rem; right: .75rem; top: 4.4rem; width: auto; }
    .member-foot { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
    .bn-member { grid-template-columns: repeat(5, minmax(0, 1fr)); }

    .hub-hero { padding: 1.25rem; border-radius: 22px; gap: 1rem; }
    .hub-avatar { width: 3rem; height: 3rem; font-size: 1.1rem; border-radius: 14px; }
    .hub-today { flex: 1 1 100%; padding: .85rem; }
    .hub-today dd { font-size: 1rem; }
    .hub-plan { flex-wrap: wrap; }
    .hub-plan .button { width: 100%; justify-content: center; }
    .hub-insight { flex-wrap: wrap; padding: 1rem; }
    .hub-insight > div { flex: 1 1 calc(100% - 3.8rem); }
    .hub-insight .hub-link { margin-left: 3.6rem; white-space: normal; }
    .hub-grid { grid-template-columns: minmax(0, 1fr); }
    .hub-card { padding: 1.15rem; border-radius: 20px; }
    .hub-stats dd { font-size: 1rem; }
    .hub-stats > div { padding: .7rem; }

    .journal-top { grid-template-columns: minmax(0, 1fr); }
    .j-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .j-mini > div { padding: .9rem 1rem; border-radius: 16px; }
    .j-kpi-grid > div { padding: .8rem .75rem; }
    .j-kpi-grid dd { font-size: .95rem; }
    .journal-section { padding: 1.1rem; }
    .jtabs { border-radius: 16px; }

    .mt-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .mt-tile { padding: .9rem; }
    .mp-head { margin-top: 0; }
    .mp-head .button { width: 100%; justify-content: center; }
}

/* ---------- โหมดมืด ---------- */
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] body:has(.mh) { background: var(--paper); }
    html[data-theme="auto"] .mh { background: rgba(17, 34, 30, .92); }
    html[data-theme="auto"] .mh-nav a, html[data-theme="auto"] .mh-icon { color: var(--ink-soft); }
    html[data-theme="auto"] .mh-nav a:hover, html[data-theme="auto"] .mh-nav a.on, html[data-theme="auto"] .mh-icon:hover, html[data-theme="auto"] .mh-pop[open] > .mh-icon { color: var(--mint); background: rgba(255, 255, 255, .05); }
    html[data-theme="auto"] .mh-panel { background: var(--surface); color: var(--ink); border-color: var(--rule); }
    html[data-theme="auto"] .mh-note > a:hover, html[data-theme="auto"] .mh-user-panel > a:hover, html[data-theme="auto"] .mh-logout:hover { background: rgba(255, 255, 255, .05); }
    html[data-theme="auto"] .mh-note-body span, html[data-theme="auto"] .mh-user-panel > a, html[data-theme="auto"] .mh-logout { color: var(--ink-soft); }
    html[data-theme="auto"] .mh-user-panel .lang-switch { background: var(--paper); }
    html[data-theme="auto"] .mh-user-panel .lang-switch a[aria-current="true"] { background: var(--surface); color: var(--mint); }
    html[data-theme="auto"] .mh-badge { box-shadow: 0 0 0 2px var(--surface); }
    html[data-theme="auto"] .mp-head h1, html[data-theme="auto"] .journal-head h1, html[data-theme="auto"] .hub-card h2, html[data-theme="auto"] .hub-insight-text, html[data-theme="auto"] .j-insights b, html[data-theme="auto"] .hub-stats dd, html[data-theme="auto"] .hub-tiles a, html[data-theme="auto"] .mt-tile, html[data-theme="auto"] .ml-topics a { color: var(--ink); }
    html[data-theme="auto"] .hub-card, html[data-theme="auto"] .me-card, html[data-theme="auto"] .j-chart, html[data-theme="auto"] .j-insights, html[data-theme="auto"] .journal-section, html[data-theme="auto"] .journal-filters, html[data-theme="auto"] .jtabs, html[data-theme="auto"] .hub-insight, html[data-theme="auto"] .j-kpi, html[data-theme="auto"] .j-mini > div, html[data-theme="auto"] .mt-tile {
        background: var(--surface); border-color: var(--rule); box-shadow: none;
    }
    html[data-theme="auto"] .hub-next, html[data-theme="auto"] .hub-tiles a, html[data-theme="auto"] .ml-topics a, html[data-theme="auto"] .hub-stats, html[data-theme="auto"] .hub-stats > div, html[data-theme="auto"] .j-kpi-grid > div { background: transparent; border-color: var(--rule); }
    html[data-theme="auto"] .hub-meter { background: var(--rule); }
    html[data-theme="auto"] .j-insights li { background: rgba(225, 29, 72, .08); }
    html[data-theme="auto"] .j-insights li.tone-good { background: rgba(5, 150, 105, .1); }
    html[data-theme="auto"] .hub-plan { background: var(--gold-wash); border-color: #5A3423; }
    html[data-theme="auto"] .hub-plan b { color: #FED7AA; }
    html[data-theme="auto"] .eq-ylab { background: rgba(17, 34, 30, .85); }
    html[data-theme="auto"] .ml-list .is-next a { background: var(--brand-wash); border-color: var(--rule); }
    html[data-theme="auto"] .ml-tutor { background: var(--surface); }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] body:has(.mh) { background: var(--paper); }
    html[data-theme="dark"] .mh { background: rgba(17, 34, 30, .92); }
    html[data-theme="dark"] .mh-nav a, html[data-theme="dark"] .mh-icon { color: var(--ink-soft); }
    html[data-theme="dark"] .mh-nav a:hover, html[data-theme="dark"] .mh-nav a.on, html[data-theme="dark"] .mh-icon:hover, html[data-theme="dark"] .mh-pop[open] > .mh-icon { color: var(--mint); background: rgba(255, 255, 255, .05); }
    html[data-theme="dark"] .mh-panel { background: var(--surface); color: var(--ink); border-color: var(--rule); }
    html[data-theme="dark"] .mh-note > a:hover, html[data-theme="dark"] .mh-user-panel > a:hover, html[data-theme="dark"] .mh-logout:hover { background: rgba(255, 255, 255, .05); }
    html[data-theme="dark"] .mh-note-body span, html[data-theme="dark"] .mh-user-panel > a, html[data-theme="dark"] .mh-logout { color: var(--ink-soft); }
    html[data-theme="dark"] .mh-user-panel .lang-switch { background: var(--paper); }
    html[data-theme="dark"] .mh-user-panel .lang-switch a[aria-current="true"] { background: var(--surface); color: var(--mint); }
    html[data-theme="dark"] .mh-badge { box-shadow: 0 0 0 2px var(--surface); }
    html[data-theme="dark"] .mp-head h1, html[data-theme="dark"] .journal-head h1, html[data-theme="dark"] .hub-card h2, html[data-theme="dark"] .hub-insight-text, html[data-theme="dark"] .j-insights b, html[data-theme="dark"] .hub-stats dd, html[data-theme="dark"] .hub-tiles a, html[data-theme="dark"] .mt-tile, html[data-theme="dark"] .ml-topics a { color: var(--ink); }
    html[data-theme="dark"] .hub-card, html[data-theme="dark"] .me-card, html[data-theme="dark"] .j-chart, html[data-theme="dark"] .j-insights, html[data-theme="dark"] .journal-section, html[data-theme="dark"] .journal-filters, html[data-theme="dark"] .jtabs, html[data-theme="dark"] .hub-insight, html[data-theme="dark"] .j-kpi, html[data-theme="dark"] .j-mini > div, html[data-theme="dark"] .mt-tile {
        background: var(--surface); border-color: var(--rule); box-shadow: none;
    }
    html[data-theme="dark"] .hub-next, html[data-theme="dark"] .hub-tiles a, html[data-theme="dark"] .ml-topics a, html[data-theme="dark"] .hub-stats, html[data-theme="dark"] .hub-stats > div, html[data-theme="dark"] .j-kpi-grid > div { background: transparent; border-color: var(--rule); }
    html[data-theme="dark"] .hub-meter { background: var(--rule); }
    html[data-theme="dark"] .j-insights li { background: rgba(225, 29, 72, .08); }
    html[data-theme="dark"] .j-insights li.tone-good { background: rgba(5, 150, 105, .1); }
    html[data-theme="dark"] .hub-plan { background: var(--gold-wash); border-color: #5A3423; }
    html[data-theme="dark"] .hub-plan b { color: #FED7AA; }
    html[data-theme="dark"] .eq-ylab { background: rgba(17, 34, 30, .85); }
    html[data-theme="dark"] .ml-list .is-next a { background: var(--brand-wash); border-color: var(--rule); }
    html[data-theme="dark"] .ml-tutor { background: var(--surface); }


/* ---------- ชวนเพื่อน ---------- */
.hub-invite {
    display: flex; align-items: center; gap: .9rem; margin: 0 0 1rem; padding: .95rem 1.2rem; border-radius: 20px;
    background: linear-gradient(120deg, #FFF7ED, #FEF3C7); border: 1px solid #FDE68A; color: #78350F; text-decoration: none;
}
.hub-invite:hover { border-color: #F59E0B; }
.hub-invite-ico { font-size: 1.5rem; }
.hub-invite > span:nth-child(2) { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.hub-invite b { font-size: .92rem; }
.hub-invite small { font-size: .78rem; color: #92400E; }
.hub-invite-go { font-size: 1.4rem; color: #D97706; }
.inv-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.inv-link { display: flex; gap: .5rem; }
.inv-link input { flex: 1; min-width: 0; height: 2.9rem; padding: 0 .9rem; border-radius: 12px; border: 1px solid #E2E8F0; background: #F8FAF9; font: inherit; font-size: .92rem; color: #10251F; }
.inv-link .button { border-radius: 12px; flex: none; }
.inv-apps { display: flex; flex-wrap: wrap; gap: .5rem; }
.inv-apps a { padding: .45rem .9rem; border-radius: 999px; background: #F1F5F3; color: #065F46; font-size: .82rem; font-weight: 700; text-decoration: none; }
.inv-apps a:hover { background: #D1FAE5; }
.inv-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .4rem; font-size: .88rem; color: #475569; }
.inv-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inv-friends { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.inv-friends li { display: flex; align-items: center; gap: .7rem; padding: .55rem .4rem; border-bottom: 1px solid #F1F5F9; }
.inv-av { width: 2rem; height: 2rem; flex: none; display: grid; place-items: center; border-radius: 10px; background: #D1FAE5; color: #065F46; font-weight: 800; font-size: .8rem; }
.inv-name { flex: 1; min-width: 0; display: grid; }
.inv-name b { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-name small { font-size: .7rem; color: #94A3B8; }
.inv-tag { flex: none; padding: .2rem .55rem; border-radius: 999px; background: #F1F5F9; color: #64748B; font-size: .7rem; font-weight: 700; }
.inv-tag.is-paid { background: #ECFDF5; color: #047857; }
.ref-note { margin: .25rem 0 1rem; padding: .7rem .9rem; border-radius: 12px; background: #FEF3C7; color: #78350F; font-size: .9rem; font-weight: 600; }
@media (max-width: 760px) {
    .inv-grid { grid-template-columns: minmax(0, 1fr); }
    .inv-link { flex-direction: column; }
    .inv-link input { font-size: 16px; }
    .inv-link .button { width: 100%; justify-content: center; }
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .hub-invite { background: var(--gold-wash); border-color: #5A3423; color: #FED7AA; }
    html[data-theme="auto"] .hub-invite small { color: #FDBA74; }
    html[data-theme="auto"] .inv-link input { background: var(--paper); border-color: var(--rule); color: var(--ink); }
    html[data-theme="auto"] .inv-apps a { background: var(--paper); color: var(--mint); }
    html[data-theme="auto"] .inv-friends li { border-color: var(--rule); }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] .hub-invite { background: var(--gold-wash); border-color: #5A3423; color: #FED7AA; }
    html[data-theme="dark"] .hub-invite small { color: #FDBA74; }
    html[data-theme="dark"] .inv-link input { background: var(--paper); border-color: var(--rule); color: var(--ink); }
    html[data-theme="dark"] .inv-apps a { background: var(--paper); color: var(--mint); }
    html[data-theme="dark"] .inv-friends li { border-color: var(--rule); }


/* ---------- Backtest ---------- */
.mp-kicker a { color: inherit; text-decoration: none; }
.mp-kicker a:hover { text-decoration: underline; }
.bt-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.bt-card {
    position: relative; display: grid; gap: .45rem; align-content: start; padding: 1.35rem; border-radius: 22px; background: #fff;
    border: 1px solid rgba(226, 232, 240, .85); box-shadow: 0 6px 24px rgba(20, 55, 46, .04); color: #10251F; text-decoration: none;
    transition: transform .15s, border-color .15s;
}
.bt-card:hover { transform: translateY(-2px); border-color: #A7F3D0; }
.bt-card.is-soon { opacity: .6; pointer-events: none; }
.bt-card b { font-family: var(--font-head); font-size: 1.05rem; }
.bt-card small { font-size: .82rem; color: #64748B; line-height: 1.55; }
.bt-card .hub-tile-ico { background: #ECFDF5; box-shadow: none; }
.bt-badge { position: absolute; top: 1.2rem; right: 1.2rem; padding: .2rem .6rem; border-radius: 999px; background: #ECFDF5; color: #047857; font-size: .7rem; font-weight: 800; }
.bt-badge.is-soon { background: #F1F5F9; color: #64748B; }
.bt-badge.is-pro { background: #FFF7ED; color: #C2410C; }
.bt-empty { text-align: center; align-items: center; }

.wi-compare { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.wi-kpi { display: grid; gap: .2rem; padding: 1rem 1.1rem; border-radius: 18px; background: #fff; border: 1px solid rgba(226, 232, 240, .85); min-width: 0; }
.wi-kpi > span { font-size: .72rem; color: #94A3B8; }
.wi-kpi b { font-family: var(--font-head); font-size: 1.25rem; color: #10251F; white-space: nowrap; }
.wi-kpi small { font-size: .7rem; color: #94A3B8; display: flex; flex-wrap: wrap; gap: .1rem .4rem; }
.wi-kpi em { font-style: normal; font-weight: 800; }
.wi-kpi em.pos { color: #059669; }
.wi-kpi em.neg { color: #E11D48; }
.wi-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.wi-range { display: flex; gap: .3rem; }
.wi-range .chip { border-radius: 9px; font-size: .75rem; padding: .25rem .65rem; }
.wi-range .chip.on { background: #065F46; border-color: #065F46; color: #fff; }
.cmp-chart { position: relative; }
.cmp-chart svg { display: block; width: 100%; height: 14rem; overflow: visible; }
.cmp-a, .cmp-b { fill: none; stroke-width: 2.4; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.cmp-a { stroke: #94A3B8; stroke-dasharray: 5 4; }
.cmp-b { stroke: #059669; }
.cmp-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .78rem; color: #64748B; }
.cmp-key::before { content: ""; display: inline-block; width: 1.1rem; height: 3px; margin-right: .4rem; vertical-align: middle; border-radius: 2px; }
.cmp-key.a::before { background: #94A3B8; }
.cmp-key.b::before { background: #059669; }
.cmp-key b { color: #10251F; margin-left: .25rem; }
.wi-sub { margin: .5rem 0 0; font-size: .85rem; font-weight: 700; color: #10251F; }
.wi-ideas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.wi-idea { display: grid; gap: .15rem; text-align: left; padding: .75rem .85rem; border-radius: 14px; border: 1px solid #D1FAE5; background: #F0FDF4; font: inherit; cursor: pointer; }
.wi-idea:hover { border-color: #34D399; }
.wi-idea b { font-size: .82rem; color: #064E3B; }
.wi-idea span { font-family: var(--font-head); font-weight: 700; }
.wi-idea span.pos { color: #059669; }
.wi-idea small { font-size: .68rem; color: #64748B; }
.wi-rules { gap: .55rem; }
.wi-label { margin: .4rem 0 0; font-size: .74rem; font-weight: 700; color: #475569; }
.wi-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.wi-hours { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.wi-chip {
    min-height: 2.1rem; padding: .25rem .6rem; border-radius: 9px; border: 1px solid #D1FAE5; background: #ECFDF5; color: #065F46;
    font: inherit; font-size: .74rem; font-weight: 700; cursor: pointer;
}
.wi-hours .wi-chip { padding: .25rem 0; }
.wi-chip.off { background: #F8FAFC; border-color: #E2E8F0; color: #CBD5E1; text-decoration: line-through; }
.wi-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.wi-nums label { display: grid; gap: .3rem; font-size: .7rem; color: #64748B; }
.wi-nums input { min-height: 2.5rem; padding: .35rem .6rem; border-radius: 10px; border: 1px solid #E2E8F0; background: #F8FAF9; font: inherit; font-size: .9rem; min-width: 0; }
.wi-note { margin: .4rem 0 0; font-size: .68rem; color: #94A3B8; line-height: 1.6; }
@media (max-width: 1024px) {
    .wi-grid { grid-template-columns: minmax(0, 1fr); }
    .wi-compare { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .bt-cards { grid-template-columns: minmax(0, 1fr); }
    .wi-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wi-hours { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .wi-nums { grid-template-columns: minmax(0, 1fr); }
    .wi-nums input { font-size: 16px; }
    .wi-ideas { grid-template-columns: minmax(0, 1fr); }
    .mh-actions { gap: .35rem; }
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .bt-card, html[data-theme="auto"] .wi-kpi { background: var(--surface); border-color: var(--rule); box-shadow: none; color: var(--ink); }
    html[data-theme="auto"] .wi-kpi b, html[data-theme="auto"] .cmp-key b, html[data-theme="auto"] .wi-sub { color: var(--ink); }
    html[data-theme="auto"] .wi-chip { background: rgba(52, 211, 153, .12); border-color: #1F5C47; color: #A7F3D0; }
    html[data-theme="auto"] .wi-chip.off { background: transparent; border-color: var(--rule); color: #4B635C; }
    html[data-theme="auto"] .wi-idea { background: rgba(52, 211, 153, .08); border-color: #1F5C47; }
    html[data-theme="auto"] .wi-idea b { color: #A7F3D0; }
    html[data-theme="auto"] .wi-nums input { background: var(--paper); border-color: var(--rule); color: var(--ink); }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] .bt-card, html[data-theme="dark"] .wi-kpi { background: var(--surface); border-color: var(--rule); box-shadow: none; color: var(--ink); }
    html[data-theme="dark"] .wi-kpi b, html[data-theme="dark"] .cmp-key b, html[data-theme="dark"] .wi-sub { color: var(--ink); }
    html[data-theme="dark"] .wi-chip { background: rgba(52, 211, 153, .12); border-color: #1F5C47; color: #A7F3D0; }
    html[data-theme="dark"] .wi-chip.off { background: transparent; border-color: var(--rule); color: #4B635C; }
    html[data-theme="dark"] .wi-idea { background: rgba(52, 211, 153, .08); border-color: #1F5C47; }
    html[data-theme="dark"] .wi-idea b { color: #A7F3D0; }
    html[data-theme="dark"] .wi-nums input { background: var(--paper); border-color: var(--rule); color: var(--ink); }


/* ---------- ทดสอบกลยุทธ์ ---------- */
.st-grid { display: grid; grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.st-form { gap: .55rem; position: sticky; top: 5.5rem; }
.st-out { display: grid; gap: 1rem; min-width: 0; }
.st-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .5rem; }
.st-row label, .st-form > label { display: grid; gap: .3rem; font-size: .7rem; font-weight: 600; color: #64748B; }
.st-row input, .st-row select { min-height: 2.5rem; padding: .3rem .6rem; border-radius: 10px; border: 1px solid #E2E8F0; background: #F8FAF9; font: inherit; font-size: .85rem; color: #10251F; min-width: 0; width: 100%; }
.st-hours { display: flex; align-items: center; gap: .3rem; }
.st-hours span { color: #94A3B8; }
.st-templates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.st-tpl { display: grid; gap: .1rem; text-align: left; padding: .6rem .7rem; border-radius: 12px; border: 1px solid #E2E8F0; background: #fff; font: inherit; cursor: pointer; }
.st-tpl b { font-size: .8rem; color: #10251F; }
.st-tpl small { font-size: .66rem; color: #94A3B8; line-height: 1.4; }
.st-tpl.on { border-color: #059669; background: #ECFDF5; box-shadow: inset 0 0 0 1px #059669; }
.st-check { display: flex !important; align-items: center; gap: .5rem; font-size: .78rem !important; color: #334155 !important; }
.st-check input { accent-color: #059669; width: 1rem; height: 1rem; }
.st-run { margin-top: .5rem; width: 100%; justify-content: center; border-radius: 12px; min-height: 3rem; }
.st-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; }
.st-kpis b.pos { color: #059669; }
.st-kpis b.neg { color: #E11D48; }
.st-hint ol { margin: 0; padding-left: 1.2rem; display: grid; gap: .4rem; font-size: .88rem; color: #475569; }
.st-table { font-size: .78rem; }
@media (max-width: 1024px) {
    .st-grid { grid-template-columns: minmax(0, 1fr); }
    .st-form { position: static; }
    .st-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .st-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .st-row input, .st-row select { font-size: 16px; }
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .st-row input, html[data-theme="auto"] .st-row select { background: var(--paper); border-color: var(--rule); color: var(--ink); }
    html[data-theme="auto"] .st-tpl { background: var(--surface); border-color: var(--rule); }
    html[data-theme="auto"] .st-tpl b, html[data-theme="auto"] .st-check { color: var(--ink) !important; }
    html[data-theme="auto"] .st-tpl.on { background: rgba(52, 211, 153, .12); }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] .st-row input, html[data-theme="dark"] .st-row select { background: var(--paper); border-color: var(--rule); color: var(--ink); }
    html[data-theme="dark"] .st-tpl { background: var(--surface); border-color: var(--rule); }
    html[data-theme="dark"] .st-tpl b, html[data-theme="dark"] .st-check { color: var(--ink) !important; }
    html[data-theme="dark"] .st-tpl.on { background: rgba(52, 211, 153, .12); }


/* ---------- Replay ---------- */
.rp { --rp-bg: #FFFFFF; --rp-grid: #EEF2F0; --rp-text: #64748B; }
.rp-setup { gap: .75rem; }
.rp-setup .button { width: fit-content; border-radius: 12px; }
.rp-stage { gap: .75rem; }
.rp-top { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.rp-top b { font-family: var(--font-head); font-size: 1.05rem; }
.rp-clock { font-size: .8rem; color: #64748B; }
.rp-price { margin-left: auto; font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
.rp-canvas-wrap { border-radius: 14px; overflow: hidden; border: 1px solid #EEF2F0; }
.rp-canvas-wrap canvas { display: block; width: 100%; touch-action: pan-y; }
.rp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.rp-btn { min-height: 2.5rem; min-width: 2.75rem; padding: .3rem .8rem; border-radius: 10px; border: 1px solid #E2E8F0; background: #fff; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.rp-btn:hover { border-color: #A7F3D0; }
.rp-speed, .rp-ema { display: flex; align-items: center; gap: .35rem; font-size: .75rem; color: #64748B; }
.rp-speed select { min-height: 2.5rem; border-radius: 10px; border: 1px solid #E2E8F0; padding: 0 .4rem; font: inherit; }
.rp-ema input { accent-color: #059669; }
.rp-order { display: grid; gap: .6rem; padding: .9rem; border-radius: 16px; background: #F8FAF9; border: 1px solid #EEF2F0; }
.rp-order-btns { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; }
.rp-buy, .rp-sell, .rp-close { min-height: 3rem; border-radius: 12px; border: 0; font: inherit; font-weight: 800; letter-spacing: .04em; color: #fff; cursor: pointer; }
.rp-buy { background: #059669; }
.rp-sell { background: #E11D48; }
.rp-close { padding: 0 1rem; background: #334155; letter-spacing: 0; }
.rp-buy:disabled, .rp-sell:disabled, .rp-close:disabled { opacity: .35; cursor: default; }
.rp-pos { margin: 0; min-height: 1.2rem; font-size: .8rem; font-weight: 700; color: #334155; }
.rp-pos.pos { color: #059669; }
.rp-pos.neg { color: #E11D48; }
.rp-stats { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.rp-stats > div { padding: .6rem .75rem; border-radius: 12px; border: 1px solid #EEF2F0; }
.rp-stats dt { font-size: .66rem; color: #94A3B8; }
.rp-stats dd { margin: .2rem 0 0; font-family: var(--font-head); font-weight: 700; }
.rp-stats dd.pos { color: #059669; }
.rp-stats dd.neg { color: #E11D48; }
.rp-trades { margin: 0; padding-left: 1.2rem; display: grid; gap: .2rem; font-size: .76rem; }
.rp-trades li.pos { color: #047857; }
.rp-trades li.neg { color: #BE123C; }
.rp-end { display: flex; gap: .5rem; flex-wrap: wrap; }
.rp-end .button { border-radius: 12px; }
.rp-history { margin-top: 1rem; }
@media (max-width: 760px) {
    .rp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rp-order-btns { grid-template-columns: 1fr 1fr; }
    .rp-close { grid-column: 1 / -1; }
    .rp-setup .button { width: 100%; justify-content: center; }
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .rp { --rp-bg: #11221E; --rp-grid: #1B302A; --rp-text: #9AAEA8; }
    html[data-theme="auto"] .rp-canvas-wrap, html[data-theme="auto"] .rp-stats > div { border-color: var(--rule); }
    html[data-theme="auto"] .rp-btn, html[data-theme="auto"] .rp-speed select { background: var(--surface); border-color: var(--rule); color: var(--ink); }
    html[data-theme="auto"] .rp-order { background: var(--paper); border-color: var(--rule); }
    html[data-theme="auto"] .rp-pos { color: var(--ink); }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] .rp { --rp-bg: #11221E; --rp-grid: #1B302A; --rp-text: #9AAEA8; }
    html[data-theme="dark"] .rp-canvas-wrap, html[data-theme="dark"] .rp-stats > div { border-color: var(--rule); }
    html[data-theme="dark"] .rp-btn, html[data-theme="dark"] .rp-speed select { background: var(--surface); border-color: var(--rule); color: var(--ink); }
    html[data-theme="dark"] .rp-order { background: var(--paper); border-color: var(--rule); }
    html[data-theme="dark"] .rp-pos { color: var(--ink); }

.rp [hidden] { display: none !important; }

/* ---------- MT5 Strategy Tester ---------- */
.mt5-upload { margin-bottom: 1rem; }
.mt5-up-row { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.mt5-up-row > div { flex: 1; min-width: 12rem; display: grid; gap: .15rem; }
.mt5-up-row b { font-size: .95rem; }
.mt5-up-row small { font-size: .74rem; color: #94A3B8; }
.mt5-up-row .hub-tile-ico { background: #ECFDF5; box-shadow: none; }
.mt5-pick { position: relative; overflow: hidden; border-radius: 12px; cursor: pointer; }
.mt5-pick input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mt5-head { margin-bottom: 1rem; }
.mt5-head h2 { font-size: 1.3rem; }
.mt5-head p { margin: .2rem 0 0; font-size: .8rem; }
.mt5-flags { margin: 1rem 0; border-color: #FDE68A; background: #FFFBEB; }
.mt5-flags h2 { font-size: 1rem; color: #92400E; }
.mt5-flags ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; font-size: .84rem; color: #78350F; }
.mt5-months { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; align-items: end; height: 7rem; }
.mt5-months span { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.mt5-months i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: #10B981; }
.mt5-months span.neg i { background: #F43F5E; }
.mt5-months small { font-size: .5rem; color: #94A3B8; margin-top: .2rem; white-space: nowrap; }
.mt5-ai-text { font-size: .9rem; }
.mt5-ai-text h1, .mt5-ai-text h2, .mt5-ai-text h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.mt5-raw { margin-top: 1rem; }
.mt5-raw summary { cursor: pointer; font-weight: 700; font-size: .88rem; }
.mt5-inputs { font-size: .74rem; color: #64748B; line-height: 1.7; overflow-wrap: anywhere; }
@media (max-width: 760px) { .mt5-months small { display: none; } .mt5-pick { width: 100%; justify-content: center; } }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .mt5-flags { background: var(--gold-wash); border-color: #5A3423; }
    html[data-theme="auto"] .mt5-flags h2, html[data-theme="auto"] .mt5-flags ul { color: #FED7AA; }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] .mt5-flags { background: var(--gold-wash); border-color: #5A3423; }
    html[data-theme="dark"] .mt5-flags h2, html[data-theme="dark"] .mt5-flags ul { color: #FED7AA; }


/* ---------- EA (MT4/MT5) ---------- */
.ea-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ea-state { padding: .25rem .7rem; border-radius: 999px; background: #F1F5F9; color: #64748B; font-size: .74rem; font-weight: 800; white-space: nowrap; }
.ea-state.is-on { background: #ECFDF5; color: #047857; }
.ea-state.is-wait { background: #FFF7ED; color: #C2410C; }
.ea-once { margin: 0 0 .6rem; padding: .7rem .9rem; border-radius: 12px; background: #FFFBEB; color: #92400E; font-size: .86rem; font-weight: 600; }
.ea-key .inv-link input { font-family: var(--font-mono, monospace); font-size: .85rem; }
.ea-meta { display: grid; gap: .45rem; margin: 1rem 0; }
.ea-meta div { display: flex; justify-content: space-between; gap: 1rem; font-size: .86rem; }
.ea-meta dt { color: #64748B; }
.ea-meta dd { margin: 0; font-weight: 700; color: #10251F; text-align: right; }
.ea-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.ea-actions form { margin: 0; }
.ea-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .55rem; font-size: .88rem; color: #475569; line-height: 1.55; }
.ea-steps code { display: inline-block; margin-top: .2rem; padding: .1rem .45rem; border-radius: 6px; background: #F1F5F3; color: #065F46; font-size: .82rem; word-break: break-all; }
.ea-sub { margin: 1.6rem 0 .8rem; font-size: 1.1rem; }
.ea-files { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.ea-file { display: flex; flex-direction: column; gap: .6rem; }
.ea-file p { margin: 0; font-size: .88rem; color: #475569; }
.ea-file-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.ea-file-head h3 { margin: 0; font-size: 1rem; }
.ea-file .bt-badge, .st-ea .bt-badge { position: static; display: inline-block; vertical-align: middle; flex: none; }
.ea-points { margin: 0; padding-left: 1.1rem; display: grid; gap: .3rem; font-size: .84rem; color: #334155; flex: 1; }
.ea-dl { display: flex; flex-wrap: wrap; gap: .5rem; }
.ea-file .wi-note { margin: 0; }
.ea-disclaimer { margin-top: 1.2rem; }
.st-ea { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.st-ea h2 { margin: 0 0 .25rem; }
.st-ea p { margin: 0; font-size: .86rem; }
.st-ea .button { flex: none; }
@media (max-width: 1024px) {
    .ea-files { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
    .ea-grid { grid-template-columns: minmax(0, 1fr); }
    .st-ea { flex-direction: column; align-items: stretch; }
    .st-ea .button, .ea-dl .button, .ea-actions .button { width: 100%; justify-content: center; }
    .ea-actions form, .ea-dl a { flex: 1 1 100%; }
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .ea-state { background: rgba(148, 163, 184, .15); color: #CBD5E1; }
    html[data-theme="auto"] .ea-state.is-on { background: rgba(16, 185, 129, .15); color: #6EE7B7; }
    html[data-theme="auto"] .ea-state.is-wait { background: rgba(251, 146, 60, .15); color: #FDBA74; }
    html[data-theme="auto"] .ea-once { background: rgba(251, 191, 36, .12); color: #FCD34D; }
    html[data-theme="auto"] .ea-meta dt, html[data-theme="auto"] .ea-file p, html[data-theme="auto"] .ea-steps, html[data-theme="auto"] .ea-points { color: var(--muted, #94A3B8); }
    html[data-theme="auto"] .ea-meta dd { color: var(--ink); }
    html[data-theme="auto"] .ea-steps code { background: rgba(16, 185, 129, .12); color: #6EE7B7; }
}
/* โหมดมืดที่เลือกในหลังบ้าน */
html[data-theme="dark"] .ea-state { background: rgba(148, 163, 184, .15); color: #CBD5E1; }
    html[data-theme="dark"] .ea-state.is-on { background: rgba(16, 185, 129, .15); color: #6EE7B7; }
    html[data-theme="dark"] .ea-state.is-wait { background: rgba(251, 146, 60, .15); color: #FDBA74; }
    html[data-theme="dark"] .ea-once { background: rgba(251, 191, 36, .12); color: #FCD34D; }
    html[data-theme="dark"] .ea-meta dt, html[data-theme="dark"] .ea-file p, html[data-theme="dark"] .ea-steps, html[data-theme="dark"] .ea-points { color: var(--muted, #94A3B8); }
    html[data-theme="dark"] .ea-meta dd { color: var(--ink); }
    html[data-theme="dark"] .ea-steps code { background: rgba(16, 185, 129, .12); color: #6EE7B7; }

