@media(max-width:1180px) {
/* Optional pot view; income chart styling stays with its existing modules. */
.planViewSwitch { display: flex; gap: 3px; padding: 3px; margin: 10px 0 14px; border: 1px solid #dce5e0; border-radius: 14px; background: #f6f8f7; width: min(100%, 380px); box-sizing: border-box; pointer-events: auto; }
.planViewSwitch button { flex: 1; min-height: 40px; border: 0; border-radius: 11px; padding: 7px 10px; font: inherit; font-size: 14px; font-weight: 600; background: transparent; color: #687872; cursor: pointer; }
.planViewSwitch button[aria-pressed="true"] { background: #347e66; color: white; box-shadow: 0 2px 6px #245b4520; }
.planViewSwitch button:focus-visible { outline: 2px solid #347e66; outline-offset: 3px; }
#planPotHeader[hidden], #planPotPanel[hidden], #planPotEmpty[hidden] { display: none !important; }
#planPotHeader { position: relative; padding-right: 125px; margin-top: 6px; }
#planPotTitle { font-size: 17px; font-weight: 600; color: #667085; }
#planPotValue { font-size: clamp(32px, 4vw, 48px); font-weight: 650; line-height: 1.2; color: #101828; margin: 6px 0; letter-spacing: -.025em; }
#planPotBasis { font-size: 13px; color: #667085; }
#planPotPanel { position: relative; max-width: 900px; margin: 14px auto 0; text-align: center; }
#planPotChart { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
#planPotChart text { font: var(--pot-label-size, 16px) system-ui, sans-serif; fill: #667085; }
.planPotLegend { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; font-size: 12px; color: #667085; }
.planPotLegend span::before { content: ''; display: inline-block; width: 16px; border-top: 3px solid #408e73; vertical-align: middle; margin-right: 6px; }
.planPotLegend span + span::before { border-color: #ee9d08; }
#planPotSelection { position:absolute; top:var(--pot-selection-top); left:var(--pot-selection-left,0px); right:0; display:block; font-weight:600; font-size:14px; color:#344054; margin:0; }
#planPotSelection[hidden] { display:none!important; }
#planPotAge { display: block; width: calc(100% - 20px); margin: 0 auto; min-height: 44px; accent-color: #408e73; }
#planPotCalc { margin: 4px auto 0; }
#planPotEmpty { font-size: 14px; color: #667085; }

.planChartControls { display:flex; align-items:center; justify-content:space-between; gap:8px; margin:6px 0 10px; pointer-events:auto; }
.planChartControls .planViewSwitch { order:-1; width:auto; margin:0; padding:2px; border-radius:12px; }
.planChartControls .planViewSwitch button { flex:none; min-height:32px; padding:5px 9px; font-size:12px; }
.planChartControls .planMoneyControls { margin-left:0; }
.planHeroCard.is-pot-view :is(.portfolioLabel,#planTotalIncome,#planMoneyBasis,#planProjectionMeta,#planHeroHint,#planLumpSumMeta,.planLegend,#planCalcLink,.portfolioChartWrap) { visibility:hidden!important; }
.planHeroCard.is-pot-view #planPotHeader { position:absolute; top:var(--pot-header-top); left:var(--pot-header-left,0px); right:0; margin:0; padding:0; }
#planPotPanel { position:absolute; top:var(--pot-chart-top); left:var(--pot-chart-left); width:var(--pot-chart-width); max-width:none; margin:0; }
#planPotChart { height:var(--pot-chart-height); }
.planPotLegend { display:none; }
#planPotSelection { margin:0; font-size:12px; }
#planPotAge { min-height:28px; height:28px; }
#planPotCalc { font-size:11px; margin:2px auto; }
@media(max-width:760px) {
 html body .plan-hero .planHeroCard { padding-bottom:24px!important; }
 .plan-hero .planHeroSummary { max-width:none!important; width:100%!important; box-sizing:border-box; }
 .planChartControls { gap:4px; }
 .planChartControls .planViewSwitch button { padding:5px 7px; font-size:11px; }
 .planChartControls .planMoneySwitch button { padding:6px; font-size:11px; }
 #planPotTitle { font-size:12px; }
 #planPotValue { font-size:32px; margin:4px 0; }
 #planPotBasis { font-size:11px; }
}




html body .plan-hero .planHeroCard .planHeroSummary { position:relative!important; inset:auto!important; }
@media(max-width:940px) and (orientation:landscape) {
 .planHeroCard.is-pot-view #planPotHeader { display:flex; flex-direction:column; gap:3px; }
 html body .plan-hero .planHeroCard .portfolioChartWrap:has(#planDebugChart) { padding-bottom:66px!important; }
 html body .plan-hero .planHeroCard .planDebugChart { height:100%!important; }
 #planPotTitle { font-size:11px; }
 #planPotValue { font-size:28px; margin:0; }
 #planPotBasis { font-size:11px; }
 #planPotSelection { font-size:11px; }
 #planPotChart text { font-size:14px; }
 html body .plan-hero #planPotCalc { display:block!important; }
}

@media(max-width:940px) and (orientation:landscape) {
 html body .plan-hero .planHeroCard .heroOverlay { padding-top:12px!important; }
}

/* Both views share the income action row and a compact chart toolbar. */
.planChartControls .planMoneySwitch button[aria-pressed="true"] { background:#347e66; color:#fff; }
#planCalcModalFootnote .planEstimateWarning { color:#b45309; font-weight:700; }
.planChartControls { margin:6px 0 0; }
@media(max-width:760px) {
 html body .plan-hero .planHeroCard .portfolioChartWrap { margin-top:0!important; }
 html body .plan-hero .planHeroCard .planHeroSummary { margin-bottom:0!important; }
}

/* Chart controls have their own quiet header below the summary divider. */
html body .plan-hero .planChartControls { position:relative; z-index:7; visibility:visible!important; margin:0 10px 4px; padding:6px 0 0; border-top:1px solid #e2e8e4; min-height:38px; box-sizing:border-box; }
html body .plan-hero .planChartControls .planViewSwitch { border:0; border-radius:0; background:none; padding:0; gap:12px; }
html body .plan-hero .planChartControls .planViewSwitch button { padding:6px 0; border-radius:0; background:none; box-shadow:none; border-bottom:2px solid transparent; color:#687872; }
html body .plan-hero .planChartControls .planViewSwitch button[aria-pressed="true"] { color:#286b56; border-bottom-color:#347e66; }
html body .plan-hero :is(#planAskAiBtn,#planAskAiBtnMobile) { background:none!important; border:0!important; box-shadow:none!important; color:#286b56!important; font-size:12px!important; font-weight:600!important; padding:4px 0!important; min-height:32px!important; border-radius:0!important; }
html body .plan-hero :is(#planAskAiBtn,#planAskAiBtnMobile)::before { content:'✦'; display:inline-block; font-size:24px; line-height:1; margin-right:6px; color:inherit; }
html body .plan-hero #planAskAiBtnMobile { position:absolute; top:0; right:0; }
html body .plan-hero .portfolioGreeting { padding-right:64px; }

@media(max-width:940px) and (orientation:landscape) {
 html body .plan-hero .planHeroCard .portfolioChartWrap:has(#planDebugChart) { grid-template-rows:auto auto minmax(0,1fr); grid-template-columns:minmax(0,1fr); row-gap:2px; }
 html body .plan-hero .planHeroCard .portfolioChartWrap .planChartControls { grid-row:1; grid-column:1; }
 html body .plan-hero .planHeroCard .portfolioChartWrap .planLegend { grid-row:2; grid-column:1; }
 html body .plan-hero .planHeroCard .planDebugChart { grid-row:3; grid-column:1; }
}

/* Desktop keeps two balanced columns; the chart owns its full plotting height. */
@media(min-width:941px) {
 html body .plan-hero .planHeroCard { display:grid; grid-template-columns:minmax(0, 2fr) minmax(0, 3fr); gap:20px; min-height:0!important; height:auto!important; padding:24px!important; }
 html body .plan-hero .heroOverlay { position:relative!important; inset:auto!important; padding:0!important; min-width:0; pointer-events:none; }
 html body .plan-hero .planHeroCard .planHeroSummary { width:100%!important; max-width:none!important; box-sizing:border-box; padding:16px 0!important; display:block!important; pointer-events:auto; }
 html body .plan-hero .portfolioChartWrap { position:relative!important; inset:auto!important; min-width:0; padding-bottom:54px; }
 html body .plan-hero .planDebugChart { position:relative!important; inset:auto!important; height:300px!important; }
 html body .plan-hero .planChartControls { margin:0 0 8px; border-top:0; padding-top:0; }
 html body .plan-hero #planAiActions { position:static; }
 html body .plan-hero #planAskAiBtn { position:absolute; right:0; top:8px; width:auto; margin:0; }
}

/* Reserve the loaded mobile summary while its actions await relocation. */
@media(max-width:760px) {
 html body.plan-loading .planHeroSummary > .planLegend,
 html body.plan-loading .planHeroSummary > #planAiActions,
 html body.plan-loading .planHeroSummary > #planLumpSumMeta:empty { display:none!important; }
 html body.plan-loading .planHeroSummary > #planHeroHint { margin:-4px 0 0!important; }
 html body.plan-loading .planHeroCard .portfolioChartWrap::after { content:''; display:block; height:41px; }
}

/* Explicit thumb size keeps its centre aligned with the SVG age coordinate. */
#planPotAge { appearance:none; -webkit-appearance:none; padding:0; border:0; box-sizing:content-box; background:transparent; cursor:pointer; }
#planPotAge::-webkit-slider-runnable-track { height:4px; border-radius:4px; background:linear-gradient(to right,#408e73 var(--pot-age-progress,0%),#d9ddda var(--pot-age-progress,0%)); }
#planPotAge::-webkit-slider-thumb { appearance:none; -webkit-appearance:none; width:20px; height:20px; margin-top:-8px; box-sizing:border-box; border:1px solid #dce3df; border-radius:50%; background:white; box-shadow:0 1px 3px #10281820; }
#planPotAge::-moz-range-track { height:4px; border-radius:4px; background:#d9ddda; }
#planPotAge::-moz-range-progress { height:4px; border-radius:4px; background:#408e73; }
#planPotAge::-moz-range-thumb { width:20px; height:20px; box-sizing:border-box; border:1px solid #dce3df; border-radius:50%; background:white; box-shadow:0 1px 3px #10281820; }

/* Portfolio's wider landscape breakpoint must not turn a desktop Plan into a phone panel. */
@media(min-width:941px) and (max-width:1180px), (min-width:941px) and (max-height:560px) {
 html:has(.plan-hero), html body:has(.plan-hero) { overflow-y:auto!important; }
 body:has(.plan-hero) #navMount .nav { display:flex!important; }
 html body:has(.plan-hero) .portfolioMain.portfolioMain { position:relative; inset:auto; width:100%!important; max-width:1200px; height:auto; margin:24px auto 28px!important; padding:0 24px!important; overflow:visible; background:transparent; border:0; }
 html body .plan-hero { position:relative; inset:auto; width:auto; min-height:0; padding:40px 0 0!important; }
 html body .plan-hero .portfolioHeroInner { width:100%!important; max-width:1200px; min-height:0; margin:0 auto!important; padding:0 24px!important; }
 html body .plan-hero .planHeroCard { width:100%!important; border-radius:20px!important; border:1px solid #e7e9ed!important; }
 html body .plan-hero .planHeroCard::before { display:none!important; }
 html body .plan-hero .portfolioGreeting { font-size:18px!important; line-height:1.08!important; margin-bottom:6px!important; }
 html body .plan-hero .portfolioLabel { font-size:14px!important; line-height:normal!important; margin-bottom:8px!important; letter-spacing:normal!important; }
 html body .plan-hero .portfolioValue { font-size:40px; line-height:1.2; margin-bottom:8px; }
}

/* Landscape keeps controls, legend and plot in separate rows without a fading overlay. */
@media(max-width:940px) and (orientation:landscape) {
 html body .plan-hero .planHeroCard::before { display:none!important; }
 html body .plan-hero .planHeroCard .portfolioChartWrap .planLegend { position:static!important; inset:auto!important; transform:none!important; font-size:10px!important; min-height:18px; justify-content:center!important; }
 html body .plan-hero .planHeroCard .portfolioChartWrap .planLegendItem { padding:1px 4px!important; border:0; background:none!important; box-shadow:none; backdrop-filter:none; }
 html body .plan-hero .planHeroCard .portfolioChartWrap:has(#planDebugChart) { padding-bottom:54px!important; }
 html body .plan-hero .planHeroCard .planDebugChart { align-self:stretch; }
 html body .plan-hero .planChartControls { margin-left:10px; margin-right:10px; }
 html body .plan-hero #planPotAge { min-height:24px; height:24px; }
 html body .plan-hero #planPotCalc { margin:0; line-height:20px; }
}

/* A compact landscape summary leaves the chart as the primary content. */
@media(max-width:940px) and (orientation:landscape) {
 html body .plan-hero.plan-hero .planHeroCard .heroOverlay { padding:10px 12px 4px max(16px, env(safe-area-inset-left, 0px))!important; }
 html body .plan-hero.plan-hero .planHeroCard .portfolioSummary { gap:1px!important; }
 html body .plan-hero.plan-hero .planHeroCard .portfolioGreeting { font-size:12px!important; line-height:1.1!important; }
 html body .plan-hero.plan-hero .planHeroCard .portfolioLabel { font-size:10px!important; line-height:1.2!important; }
 html body .plan-hero.plan-hero .planHeroCard .portfolioValue { font-size:24px!important; line-height:1.1!important; }
 html body .plan-hero #planMoneyBasis { font-size:9px!important; margin:0!important; }
 html body .plan-hero #planHeroHint, html body .plan-hero .planHeroHintRowMobile { min-height:0!important; margin:3px 0 0!important; }
 html body .plan-hero #planHeroHint .planMetaText { font-size:10px!important; }
 html body .plan-hero .planLegend, html body .plan-hero #planPotAge { display:none!important; }
 html body .plan-hero .planHeroCard .portfolioChartWrap:has(#planDebugChart) { grid-template-rows:auto minmax(0,1fr); padding-bottom:max(40px, calc(var(--portzo-safe-bottom, env(safe-area-inset-bottom, 0px)) + 24px))!important; }
 html body .plan-hero .planHeroCard .planDebugChart { grid-row:2; }
 html body .plan-hero .planChartControls { min-height:32px; padding-top:3px; }
 html body .plan-hero #planPotCalc { margin:0 auto; }
}
@media(min-width:941px) and (max-width:1180px), (min-width:941px) and (max-height:560px) {
 html body .plan-hero { padding-top:110px!important; }
}

}

/* Desktop preserves the pre-pot income layout; the alternate view fits that frame. */
@media(min-width:1181px) {
 #planPotHeader[hidden], #planPotPanel[hidden], #planPotSelection[hidden] { display:none!important; }
 .planHeroCard.is-pot-view :is(.portfolioLabel,#planTotalIncome,#planMoneyBasis,#planProjectionMeta,#planHeroHint,#planLumpSumMeta,.planLegend,.portfolioChartWrap) { visibility:hidden!important; }
 .planHeroCard.is-pot-view #planPotHeader { position:absolute; top:var(--pot-header-top); left:var(--pot-header-left); right:0; }
 #planPotSelection { position:absolute; top:var(--pot-selection-top); left:var(--pot-selection-left); margin:0; }
 #planPotPanel { position:absolute; top:var(--pot-chart-top); left:var(--pot-chart-left); width:var(--pot-chart-width); }
 #planPotChart { display:block; width:100%; height:var(--pot-chart-height); overflow:visible; }
 #planPotChart text { font:11px Poppins, Inter, sans-serif; fill:#98a2b3; }
 #planPotChart .potAgeTick { font-size:12px; fill:#475467; }
 #planPotChart .potRetirementLabel { fill:#667085; }
 .planPotLegend, #planPotCalc, #planPotEmpty[hidden] { display:none; }
 .planChartControls { position:absolute; z-index:7; top:6px; left:58px; right:18px; visibility:visible!important; pointer-events:auto; }
 .planViewSwitch { display:flex; justify-content:flex-end; gap:14px; }
 .planViewSwitch button { padding:4px 0; font:600 12px Poppins, Inter, sans-serif; border:0; border-bottom:2px solid transparent; background:transparent; color:#687872; cursor:pointer; }
 .planViewSwitch button[aria-pressed="true"] { color:#286b56; border-bottom-color:#347e66; }
 .planViewSwitch button:focus-visible { outline:2px solid #347e66; outline-offset:2px; }
 #planPotAge { position:absolute; top:var(--pot-slider-top); left:18px; width:calc(100% - 36px)!important; margin:0!important; height:24px; accent-color:#408e73; }
 #planPotAge[hidden] { display:none; }
}
