/* FINMODEL responsive choreography V1. Only tablet/phone; desktop V45 untouched. */
.fm-mobile-engine-logic{display:none}
@media(min-width:591px) and (max-width:1024px){
 /* Retain complete native screens, but give their evidence a coherent tablet canvas. */
 body.landing-premium #builder .fm-builder-frame{height:760px!important}
 body.landing-premium #scenarios .scenario-v7-embed iframe{height:780px!important}
 #model .fm-inside-experience .model-image-pane{min-width:0}
 #model .fm-inside-viewport{height:365px}
 #formulaMotion .fmq-app{min-height:0!important}
 #formulaMotion .fmq-editforms{height:255px}
}
@media(max-width:590px){
 /* Hero keeps its established five-stage _hyperscript timeline and fits the phone without a blank ending. */
 #demo .hx-world{height:570px!important;min-height:570px!important}
 body.landing-premium #builder .fm-builder-frame{height:700px!important}
 body.landing-premium #scenarios .scenario-v7-embed iframe{height:680px!important}
 /* The model evidence is not an unreadable clipped screenshot: preserve a full image and readable live metrics. */
 #model .fm-inside-viewport{height:280px!important}
 #model .fm-inside-viewport picture,#model .fm-inside-viewport picture img{height:280px!important}
 #model .fm-inside-metric b{font-size:19px!important}
 #model .fm-inside-telemetry-head strong{font-size:10px!important}
 /* Formula: eliminate empty editor area; reserve enough space for constructor dropdown choreography. */
 #formulaMotion .fmq-app{min-height:0!important;height:auto!important}
 #formulaMotion .fmq-editforms{height:220px!important}
 #formulaMotion .fmq-grid{align-items:stretch}
 #formulaMotion .fmq-result{min-height:0!important}
 #formulaMotion .fmq-top{min-height:48px;height:auto;padding:9px 11px}
 #formulaMotion .fmq-intro p{line-height:1.45!important}
 /* Original SVG is wider than the device; use a complete, ordered native diagram only on phones. */
 #engine .fm17-scene:first-child .premium-logic{display:none!important}
 #engine .fm17-scene:first-child .flow-nodes{display:none!important}
 #engine .fm17-scene:first-child .fm-mobile-engine-logic{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));align-content:center;gap:8px;padding:8px 4px;margin:0 auto;width:100%;min-width:0;max-width:440px}
 #engine .fm-mobile-engine-step{display:flex;flex-direction:column;justify-content:center;min-height:57px;padding:9px 10px;border:1px solid #b6cee9;border-radius:10px;background:linear-gradient(130deg,#f6faff,#e8f1ff);color:#1b396b;min-width:0;box-shadow:0 4px 14px #0a254c0d;animation:fm-node-in .5s ease both}
 #engine .fm-mobile-engine-logic.fm-flow-replaying .fm-mobile-engine-step:not(.fm-flow-on){opacity:.35;transform:translateY(4px)}
 #engine .fm-mobile-engine-logic.fm-flow-replaying .fm-mobile-engine-step.fm-flow-on{opacity:1;transform:none;border-color:#60a4e8;box-shadow:0 0 0 2px #659efa55,0 6px 20px #345ab61d}
 #engine .fm-mobile-engine-step small{font-size:9px;letter-spacing:.055em;color:#53739e;font-weight:850;margin-bottom:5px}
 #engine .fm-mobile-engine-step strong{font-size:12px;line-height:1.25;color:#183f79;font-weight:800;overflow-wrap:anywhere}
 #engine .fm-mobile-engine-core{grid-column:span 2;background:linear-gradient(115deg,#315de5,#237dc3);border-color:#3c77d6;min-height:61px;text-align:center}
 #engine .fm-mobile-engine-core small,#engine .fm-mobile-engine-core strong{color:#fff}
 #engine .fm-mobile-engine-output{grid-column:span 2;background:#dff8ed;border-color:#a3dfcb;text-align:center}
 #engine .fm-mobile-engine-step:nth-child(2){animation-delay:.12s}#engine .fm-mobile-engine-step:nth-child(3){animation-delay:.25s}#engine .fm-mobile-engine-step:nth-child(4){animation-delay:.4s}#engine .fm-mobile-engine-step:nth-child(5){animation-delay:.55s}#engine .fm-mobile-engine-step:nth-child(6){animation-delay:.7s}#engine .fm-mobile-engine-step:nth-child(7){animation-delay:.85s}
 #engine .fm17-scene:first-child .fm17-visual{overflow:hidden}
 #engine .fm17-scene:first-child .flow-visual{height:auto!important;min-height:0!important;overflow:visible!important;padding:0!important;margin:0!important}
 #engine .fm17-scene:first-child .fm17-graphic{min-height:0!important}
}
@media(max-width:359px){
 #demo .hx-world{height:590px!important;min-height:590px!important}
 body.landing-premium #builder .fm-builder-frame{height:650px!important}
 body.landing-premium #scenarios .scenario-v7-embed iframe{height:565px!important}
 #engine .fm17-scene:first-child .fm-mobile-engine-logic{gap:6px;padding:5px 2px}
 #engine .fm-mobile-engine-step{padding:7px 8px;min-height:53px}
 #engine .fm-mobile-engine-step strong{font-size:11px}
 #formulaMotion .fmq-editforms{height:235px!important}
}
@keyframes fm-node-in{from{opacity:.35;transform:translateY(9px)}to{opacity:1;transform:none}}

/* HERO: 320–359 px. Four dialogue receipts must remain fully visible and readable.
   Preserve all _hyperscript states, phase timings and desktop/tablet designs. */
@media(max-width:359px){
  #demo .hx-extract{grid-template-columns:minmax(0,1fr)!important;height:188px!important;min-height:188px!important;gap:2px!important}
  #demo .hx-extract-head{grid-column:1/-1;margin:0!important}
  #demo .hx-extract-head b{font-size:10px!important;margin:1px 0!important}
  #demo .hx-receipt{min-height:32px!important;height:32px!important;padding:3px 8px!important;gap:7px!important}
  #demo .hx-receipt small{font-size:8px!important}
  #demo .hx-receipt strong{font-size:10px!important;margin-top:0!important}
}

/* HERO tablet proof: keep P&L and Cash Flow entirely inside the 3D stage. */
@media(min-width:701px) and (max-width:1024px){
  #demo .hx-proof-main{left:2%!important;width:64%!important;height:88%!important}
  #demo .hx-proof-report{width:28%!important;right:6%!important;height:40%!important}
  #demo[data-phase=complete] .hx-report-pnl{transform:translate3d(0,0,55px) rotateY(-5deg) rotateX(2deg) scale(1)!important}
  #demo[data-phase=complete] .hx-report-cf{transform:translate3d(0,0,60px) rotateY(-5deg) rotateX(2deg) scale(1)!important}
}

/* HERO phone/tablet refinement — original desktop V45 styles untouched.
   Answer cards in a readable single column and 18 modules in 2 columns on phones. */
@media(max-width:430px){
  #demo .hx-extract{display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:auto repeat(4,minmax(0,1fr))!important;gap:4px!important;height:197px!important;min-height:197px!important;padding:5px 0 0!important}
  #demo .hx-extract-head{grid-column:1!important}
  #demo .hx-receipt{height:auto!important;min-height:0!important;padding:3px 8px!important;gap:8px!important}
  #demo .hx-receipt small{font-size:10px!important;white-space:normal!important;line-height:1.14!important}
  #demo .hx-receipt strong{font-size:11px!important;line-height:1.12!important;margin-top:1px!important}
  #demo .hx-receipt-n{font-size:10px!important}
  #demo .hx-chat-panel{min-height:195px!important;max-height:240px!important}
  #demo .hx-modules{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:4px 7px!important;padding:3px 0!important;align-content:start!important}
  #demo .hx-module{height:38px!important;min-height:38px!important;max-height:38px!important;padding:4px 9px!important;gap:5px!important}
  #demo .hx-module strong{font-size:11px!important;line-height:1.08!important;overflow-wrap:anywhere!important}
  #demo .hx-module span{font-size:9px!important}
  #demo .hx-module i{font-size:10px!important}
  #demo .hx-assembly-nexus{opacity:.32!important}
}
/* Ensure the two reports really have equal width, including during transitions. */
@media(max-width:700px){
  #demo .hx-report-pnl{left:0!important;right:auto!important}
  #demo .hx-report-cf{left:auto!important;right:0!important}
  #demo .hx-proof-report{box-sizing:border-box!important}
}
/* Native _hyperscript-driven proof spotlight: model → P&L → Cash Flow → full overview.
   This expands existing real images in place; no added controls or fake calculations. */
@media(max-width:1024px){
  #demo[data-phase="complete"][data-proof="model"] .hx-proof-report{opacity:0!important;visibility:hidden!important;pointer-events:none!important}
  #demo[data-phase="complete"][data-proof="model"] .hx-proof-main{top:4%!important;height:88%!important}
  #demo[data-phase="complete"][data-proof="pnl"] .hx-proof-main,
  #demo[data-phase="complete"][data-proof="pnl"] .hx-report-cf,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-proof-main,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-report-pnl{opacity:0!important;visibility:hidden!important;pointer-events:none!important}
  #demo[data-phase="complete"][data-proof="pnl"] .hx-report-pnl,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-report-cf{position:absolute!important;display:block!important;left:4%!important;right:auto!important;top:3%!important;bottom:auto!important;width:92%!important;height:92%!important;transform:none!important;opacity:1!important;visibility:visible!important;z-index:12!important;transition:opacity .4s ease!important}
  #demo[data-phase="complete"][data-proof="pnl"] .hx-proof-report>div,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-proof-report>div{height:43px!important;padding:7px 12px!important}
  #demo[data-phase="complete"][data-proof="pnl"] .hx-proof-report b,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-proof-report b{font-size:15px!important}
  #demo[data-phase="complete"][data-proof="pnl"] .hx-proof-report span,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-proof-report span{font-size:11px!important}
  #demo[data-phase="complete"][data-proof="pnl"] .hx-proof-report img,
  #demo[data-phase="complete"][data-proof="cashflow"] .hx-proof-report img{height:calc(100% - 43px)!important;object-fit:contain!important;object-position:top center!important}
}
/* Keep each real report at its native full aspect ratio, centred in the stage:
   never stretch a 1247×525 screenshot into a tall empty white rectangle. */
@media(max-width:1024px){
 #demo[data-phase="complete"][data-proof="pnl"] .hx-report-pnl,
 #demo[data-phase="complete"][data-proof="cashflow"] .hx-report-cf{top:50%!important;height:auto!important;transform:translateY(-50%)!important;background:transparent!important;border:none!important;box-shadow:none!important;display:flex!important;flex-direction:column!important;gap:10px!important}
 #demo[data-phase="complete"][data-proof="pnl"] .hx-report-pnl>div,
 #demo[data-phase="complete"][data-proof="cashflow"] .hx-report-cf>div{flex:none!important;border:1px solid #cad9f1!important;border-radius:11px!important;background:#f2f6ff!important;height:auto!important;min-height:55px!important;padding:9px 12px!important}
 #demo[data-phase="complete"][data-proof="pnl"] .hx-report-pnl img,
 #demo[data-phase="complete"][data-proof="cashflow"] .hx-report-cf img{display:block!important;width:100%!important;height:auto!important;max-height:none!important;border:1px solid #c5d7ef!important;border-radius:11px!important;background:#fff!important;box-shadow:0 15px 35px #1c4c9e28!important;object-fit:contain!important}
}
@media(max-width:430px){
 #demo .hx-module strong{font-size:10px!important;letter-spacing:-.03em!important;hyphens:auto!important;overflow-wrap:normal!important;word-break:normal!important}
}

/* BUILDER V45 mobile content-integrity fix, 2026-11-02.
   Adjust only the builder canvas, not Hero, desktop, tablet >=701px, or playback. */
@media (min-width:591px) and (max-width:700px){
 body.landing-premium #builder .fm-builder-frame{height:865px!important}
}
@media (min-width:351px) and (max-width:590px){
 body.landing-premium #builder .fm-builder-frame{height:885px!important}
}
@media (max-width:350px){
 body.landing-premium #builder .fm-builder-frame{height:945px!important}
}

/* MODEL V45 QA 2026-11-02. The narrow two-column tablet canvas cannot
   display four horizontal metrics without clipping the ruble amount. */
@media (min-width:701px) and (max-width:820px){
  #model .fm-inside-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* FORMULA V45 QA 2026-11-02. Do not abbreviate selected metric names:
   the labels are essential to demonstrating a usable formula constructor. */
@media (max-width:700px){
  #formulaMotion .fmq-build-field{min-height:74px}
  #formulaMotion .fmq-build-field strong{
    white-space:normal;overflow:visible;text-overflow:clip;
    overflow-wrap:break-word;line-height:1.25;padding-right:13px;
  }
}

/* The operation popup extends 3px beyond the fixed 220px mobile builder
   canvas at 360–590px; reserve space only for builder stages. */
@media (min-width:360px) and (max-width:590px){
  #formulaMotion:is([data-step="7"],[data-step="8"],[data-step="9"],[data-step="10"],[data-step="11"],[data-step="12"]) .fmq-editforms{height:235px!important}
}

/* Tablet/phone: original five-step scroll narration retained.
   Mobile causal chain uses vertical links to occupy the visible scene and
   retain the final decision context through the exit to the next block. */
@media (max-width: 900px) {
 #engine #fmEngineStory .fm17-scene:not(:first-child) .fm17-graphic{justify-content:stretch!important;align-items:stretch;gap:9px!important;}
 #engine #fmEngineStory .fm17-scene:not(:first-child) .fm17-path{max-width:680px;margin-inline:auto;flex:1 1 0;min-height:0;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:repeat(4,minmax(0,1fr));gap:11px!important;}
 #engine #fmEngineStory .fm17-scene:not(:first-child) .fm17-node{height:100%;min-height:0!important;padding:5px 8px!important;gap:2px!important;}
 #engine #fmEngineStory .fm17-scene:not(:first-child) .fm17-node::after{display:block!important;content:'↓'!important;position:absolute;left:50%!important;top:calc(100% - 2px)!important;transform:translateX(-50%)!important;font-size:15px!important;line-height:15px!important;z-index:2;}
 #engine #fmEngineStory .fm17-scene:not(:first-child) .fm17-node:last-child::after{display:none!important;}
 #engine #fmEngineStory .fm17-scene:not(:first-child) .fm17-message{flex:0 0 auto;}
}

/* Narrow portrait tablets: preserve every element of the first causal chain.
   The original wide SVG clipped its decision and result endpoints at 768px. */
@media (min-width:591px) and (max-width:900px){
 #engine #fmEngineStory .fm17-scene:first-child .premium-logic{display:none!important;}
 #engine #fmEngineStory .fm17-scene:first-child .flow-nodes{display:none!important;}
 #engine #fmEngineStory .fm17-scene:first-child .fm-mobile-engine-logic{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px!important;max-width:620px;width:100%;margin:0 auto;align-content:center;}
 #engine #fmEngineStory .fm-mobile-engine-step{display:flex;flex-direction:column;justify-content:center;min-width:0;min-height:78px;padding:10px 13px;border:1px solid #b6cee9;border-radius:12px;background:linear-gradient(130deg,#f6faff,#e8f1ff);box-shadow:0 4px 14px #0a254c0d;text-align:center;}
 #engine #fmEngineStory .fm-mobile-engine-step small{font-size:10px;letter-spacing:.055em;color:#53739e;font-weight:850;margin-bottom:6px;}
 #engine #fmEngineStory .fm-mobile-engine-step strong{font-size:14px;line-height:1.25;color:#183f79;font-weight:800;overflow-wrap:anywhere;}
 #engine #fmEngineStory .fm-mobile-engine-core{grid-column:span 2;background:linear-gradient(115deg,#315de5,#237dc3);border-color:#3c77d6;min-height:75px;}
 #engine #fmEngineStory .fm-mobile-engine-core small,#engine #fmEngineStory .fm-mobile-engine-core strong{color:white;}
 #engine #fmEngineStory .fm-mobile-engine-output{grid-column:span 2;background:#dff8ed;border-color:#a3dfcb;min-height:66px;}
}
