/* ===== МОБИЛЕН (≤ 700 px): новата кожа на телефон — една колона, рейлът долу, без хоризонтален скрол ===== */
@media (max-width:700px){
  html,body{overflow-x:hidden}
  body{margin-left:0 !important;padding-bottom:58px}
  header{margin-left:0 !important;padding:0 10px;height:auto;min-height:53px;flex-wrap:wrap;gap:6px}
  .projbar{flex-wrap:wrap;margin-left:0;gap:4px}
  .projbar button,.projbar .rdChip{padding:6px 8px}
  #rdSide{display:none !important}
  .layout{flex-direction:column-reverse !important}
  .main{margin:0 !important;padding:8px !important;max-width:100vw}
  .sidebar{position:static !important;width:auto !important;max-width:100vw;transform:none !important;visibility:visible !important;pointer-events:auto !important;border-left:0 !important;top:auto !important;right:auto !important;bottom:auto !important;height:auto !important;overflow:visible !important}
  body.rdSbClosed .sidebar{display:block !important}
  #rdSbTg,#rdSbThread,#rdSideTg,#rdSideThread,.rdTongue{display:none !important}
  #rdCabMenu{width:auto !important;max-width:100%}
  .rdPartTabs{margin:8px 6px 0;flex-wrap:nowrap;overflow-x:auto}
  .rdPartTab{padding:6px 4px 5px;font-size:10.5px;min-width:56px}
  .rdPartTab small{display:none}
  .rdPrevTools{right:8px !important;top:8px !important;width:40px !important;transform:scale(.9);transform-origin:top right}
  .preview-wrap{max-width:100%;min-height:0}  .rdBox3d,#rdVp{max-width:100%;min-height:52vh}
  .card,.sec-card{max-width:100%}
  .card .body{overflow-x:auto}
  table{max-width:100%}
  #rdDocsBtn{bottom:66px;right:10px;padding:9px 12px}
  .rdCine,#rdVpCube{display:none !important}
  #rdRail{z-index:1300}
  #rdD2,.d2Screen,#rdNest,#rdWall,#rdHw,#rdPrice,#rdMats,#rdHelp{max-width:100%;overflow-x:auto}
}
@media (max-width:700px){
  /* вътрешните страници: рейлът с разделите става лента отгоре, съдържанието е на цяла ширина */
  #rdBot,#rdHw,#rdNest,#rdWall,#rdPrice{flex-direction:column !important;gap:10px}
  #rdBotRail,#rdHwRail,#rdNestRail,#rdWallRail,#rdPriceRail{width:auto !important;flex-direction:row !important;overflow-x:auto;padding:6px;gap:4px;align-self:auto !important}
  #rdBotRail .rbi,#rdHwRail .rbi,#rdNestRail .rbi,#rdWallRail .rbi,#rdPriceRail .rbi{padding:8px 10px;white-space:nowrap;font-size:12px}
  #rdBotRail .rbi .rbn,#rdHwRail .rbi .rbn,#rdNestRail .rbi .rbn,#rdWallRail .rbi .rbn,#rdPriceRail .rbi .rbn{margin-left:6px}
  #rdLevers{width:auto !important;max-width:100% !important}
  .nsBody,.d2Body{flex-direction:column !important}
  .wlSide,.mtSide{width:auto !important;border-left:0 !important;border-top:1px solid #d9dee6}
  .mtGrid{padding:8px}
  #rdBot>*,#rdHw>*,#rdNest>*,#rdWall>*,#rdPrice>*{min-width:0;max-width:100%}
}
@media (max-width:700px){
  #rdBotRail,#rdHwRail,#rdNestRail,#rdWallRail,#rdPriceRail{flex:0 0 auto !important;height:auto !important;min-height:0 !important;align-items:center}
  #rdBotRail .rbi,#rdHwRail .rbi,#rdNestRail .rbi,#rdWallRail .rbi,#rdPriceRail .rbi{align-self:center;flex:none}
}
@media (max-width:700px){
  #rdBot,#rdHw,#rdNest,#rdWall,#rdPrice{height:auto !important;min-height:0 !important}
  #rdBot>*:not(#rdBotRail),#rdHw>*:not(#rdHwRail),#rdNest>*:not(#rdNestRail),#rdWall>*:not(#rdWallRail),#rdPrice>*:not(#rdPriceRail){flex:1 1 auto !important;height:auto !important;min-height:40vh;overflow:visible !important;width:auto !important}
  .nsBody>*,.d2Body>*{flex:1 1 auto !important;height:auto !important;min-height:0}
}
@media (max-width:700px){ .rdRailThread,#rdRailThread,.rdThreadBar{display:none !important} }
@media (max-width:700px){ #demoBuyFab{bottom:66px !important;right:10px !important;padding:10px 14px !important;font-size:12.5px !important} body.__demo #rdDocsBtn,#rdDocsBtn.demo{bottom:118px !important} }
/* ===== МОБИЛЕН v2 (08.09): подредено, без припокриване ===== */
@media (max-width:700px){
  /* 3D / чертежи на цяла ширина; инструментите вдясно, а не извън екрана */
  .preview-wrap,.preview-wrap.rdPrev{width:auto !important;min-width:0 !important;margin:0 0 10px !important;display:block !important;padding:0 !important}
  .preview-wrap.rdPrev .preview-box{padding:54px 0 0 !important;width:100% !important;min-width:0 !important;max-width:100% !important}
  .rdBox3d,#rdVp,.rdBoxDraw,#rdD2{width:100% !important;min-width:0 !important;max-width:100% !important}
  .preview-wrap.rdPrev .rdPrevTools{left:auto !important;right:6px !important;top:8px !important;transform:none !important;width:40px !important}
  .preview-wrap.rdPrev .rdPrevTabs{left:8px !important;top:8px !important}
  .d2Screen{min-height:0 !important;margin:0 6px 10px !important}
  #rdD2 .d2Body > svg,#rdD2 .d2Screen > svg{width:100% !important;height:auto !important;max-height:70vh}
  .d2Modes{flex-wrap:wrap}
  /* рейлът с разделите: статичен, редовете се пренасят, златният бутон вдясно */
  #rdBotRail,#rdHwRail,#rdNestRail,#rdWallRail,#rdPriceRail{position:static !important;top:auto !important;flex-wrap:wrap !important;overflow:visible !important;padding:6px !important;gap:4px 6px !important;transition:none !important}
  #rdBotGold,#rdHwGold,#rdNestGold,#rdWallGold,#rdPriceGold{margin-left:auto;position:static !important;transform:none !important}
  #rdBotMain,#rdHwMain,#rdNestMain,#rdWallMain,#rdPriceMain{margin-top:0 !important}
  /* заглавните ленти на секциите: пренасяне, без дългите подсказки */
  #rdWallHead,#rdPriceHead,#rdNestHead,#rdHwHead,#rdBotHead,#rdLblHead{flex-wrap:wrap !important;height:auto !important;gap:8px 10px !important;padding:10px 12px !important}
  #rdWallHead .rdWallHint,#rdNestHint,.rdNestHint,.rdHwHint,.rdPriceHint{display:none !important}
  #rdNestHead .btn.small{padding:0 8px !important}
  /* разкрой: листовете на цяла ширина, страничните колони под тях */
  .nsCard{width:100% !important}
  .nsSide,.nsList,.wlSide,.wlList{width:auto !important;max-width:100% !important;border-left:0 !important;border-right:0 !important;flex:0 0 auto !important}
  .nsGrid{padding:10px}
  .nsBar{height:auto !important;flex-wrap:wrap;padding:8px 10px !important;gap:6px}
  .nsNav{flex-wrap:wrap}
  /* стената: една колона — сцена, после списъкът, после помощникът */
  .wlBody{flex-direction:column !important;display:flex !important}
  .wlStage{min-height:44vh;order:-1;flex:0 0 auto !important}
  .wlHint{display:none !important}
  .wlStage{min-height:0 !important;height:auto !important}
  .wlStage>svg{position:static !important;width:100% !important;height:auto !important;display:block}
  .wlRail{right:6px !important;top:6px !important}
  /* помощ: героят една колона, бутоните под текста */
  .hpHero{flex-direction:column !important;align-items:stretch !important;padding:16px 16px 18px !important;gap:12px !important}
  .hpHero h1{font-size:20px !important;line-height:1.2 !important}
  .hpHero .q{display:flex;flex-wrap:wrap;gap:8px}
  .hpHero .hpQ{flex:1 1 auto;text-align:center;padding:9px 10px !important}
  .hpSteps{grid-template-columns:1fr !important}
  /* лостовете на цената: плъзгачите под текста */
  #rdLevers{display:block !important;padding:10px 12px !important}
  #rdLeverHost{margin-top:8px;display:grid;grid-template-columns:1fr;gap:8px}
  /* документите за печат: 2 колони */
  .rdBotPrint .dGridBtn{grid-template-columns:repeat(2,1fr) !important}
  /* панелът с шкафа: в страницата „Дизайн“ между 3D и крой листа (skin.js го мести там) */
  #page-design > .sidebar{margin:0 0 10px !important;padding:0 !important;display:block !important}
  #page-design > .sidebar .card{border-radius:14px}
  .rdCabMenuRail,.rdCmRail{flex-wrap:wrap}
  /* фиксираните бутони да не покриват долния рейл */
  #demoBuyFab{bottom:64px !important}
  /* етикети: две колони */
  #labelsGrid{grid-template-columns:repeat(2,1fr) !important;gap:8px !important}
}
/* ===== МОБИЛЕН v3 (08.09, Кристиан): бялото до ръбовете, повече синьо под хедъра, рейлът над лентата на iPhone ===== */
@media (max-width:700px){
  .layout{padding:0 !important}  .main{padding:6px 0 0 !important}
  #page-design > .sidebar{margin:0 0 6px !important}
  .preview-wrap,.preview-wrap.rdPrev{margin:0 0 6px !important;border-radius:0 !important}
  #rdBot,#rdHw,#rdNest,#rdWall,#rdPrice{gap:6px !important;margin-top:0 !important}
  #page-design > .sidebar .card,.main .card,.main .sec-card,#rdBotRail,#rdHwRail,#rdNestRail,#rdWallRail,#rdPriceRail,#rdLblHead,#rdHwMain .card,#rdNestMain .card,.rdNsCard,.wlBody,.d2Screen{border-radius:8px !important;margin-left:0 !important;margin-right:0 !important}
  #warnings{margin:0 0 6px !important}
  #labelsGrid{padding:0 !important}
  #page-help .card{padding:8px !important}
  header{padding:6px 10px 12px !important}
  #rdRail{height:auto !important;padding:6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) !important}
  body{padding-bottom:calc(64px + env(safe-area-inset-bottom, 0px)) !important}
  #demoBuyFab{bottom:calc(70px + env(safe-area-inset-bottom, 0px)) !important}
}
/* ===== МОБИЛЕН v4 (08.09, Кристиан): стойности 2 колони, разкроят навигация под листа, чертежите без празно, рейлът с големи икони ===== */
@media (max-width:700px){
  .rdBotPanel.rdBotStats{grid-template-columns:repeat(2,1fr) !important;gap:8px !important;padding:10px !important}
  .rdBotStats .tot{width:auto !important;min-width:0 !important;max-width:none !important;padding:10px 12px !important;overflow:hidden}
  .rdBotStats .tot .rdTrow{flex-direction:column !important;align-items:flex-start !important;width:100% !important;gap:4px !important}
  .rdBotStats .tot .rdTrow span{font-size:10.5px !important;line-height:1.25 !important}
  .rdBotStats .tot .rdTrow b{font-size:22px !important;line-height:1.1 !important;white-space:nowrap}
  .nsNav{position:static !important;transform:none !important;margin:8px auto 4px !important;width:max-content;max-width:100%;flex-wrap:nowrap !important;gap:8px !important;font-size:11.5px !important;padding:7px 12px !important}
  .nsNav > *{flex:0 0 auto}
  .nsHint{display:none !important}
  .rdBoxDraw,.preview-wrap.rdPrev .rdBoxDraw,#rdD2{min-height:0 !important;height:auto !important}
  .d2Bar{height:auto !important;flex-wrap:wrap;padding:8px 10px !important;gap:6px !important}
  #rdD2 .d2Screen,#rdD2 .d2Body{overflow-x:auto !important}
  #rdD2 .d2Body > svg,#rdD2 .d2Screen > svg{min-width:640px}
  #rdRail{padding:4px 4px max(env(safe-area-inset-bottom,0px),8px) !important;justify-content:space-around !important;gap:0 !important}
  #rdRail button{width:50px !important;height:46px !important;border-radius:12px !important}
  #rdRail button svg{width:26px !important;height:26px !important;stroke-width:1.5 !important}
  body{padding-bottom:calc(58px + env(safe-area-inset-bottom,0px)) !important}
  #demoBuyFab{bottom:calc(64px + env(safe-area-inset-bottom,0px)) !important}
}
@media (max-width:700px){ .rbSub{flex-basis:100%;flex-direction:row;flex-wrap:wrap;gap:4px;margin:0;padding:2px 4px 4px;border-left:0} .rbs{padding:5px 9px;font-size:12px;background:#f3f5f9} }

/* ===== ТЕЛЕФОН v3 (14.09): горната лента на един ред, тъч ===== */
#rdHdrMore{display:none}
@media (max-width:700px){
  header .rdTop[title^="Преименувай"],header .rdTop[title^="Изтрий"],header .rdTop[title^="Бекъп"],header .rdTop[title^="Възстанови"],header .rdTop[title^="Шаблони"],
  header #licBtn,header #themeBtn,header #lockBtn,header #shopBtn,header #redoBtn{display:none !important}
  header.rdHdrOpen .rdTop[title^="Преименувай"],header.rdHdrOpen .rdTop[title^="Изтрий"],header.rdHdrOpen .rdTop[title^="Бекъп"],header.rdHdrOpen .rdTop[title^="Възстанови"],header.rdHdrOpen .rdTop[title^="Шаблони"],
  header.rdHdrOpen #licBtn,header.rdHdrOpen #themeBtn,header.rdHdrOpen #lockBtn,header.rdHdrOpen #shopBtn,header.rdHdrOpen #redoBtn{display:inline-flex !important}
  #rdHdrMore{display:inline-flex !important;align-items:center;justify-content:center;min-width:36px;font-size:18px;line-height:1;letter-spacing:.05em}
  header.rdHdrOpen #rdHdrMore{background:#e8b978;color:#1c2c44}
  header .rdSep{border-left:0 !important;margin-left:0 !important;padding-left:0 !important}
  #rdVp canvas,.rdBox3d canvas{touch-action:none}
  /* редовете на менюто — по-едри за пръст */
  .rdLiH{min-height:48px;font-size:14px}
  .rdLiH .r{max-width:52%}
  #rdCabMenu .rdLiT.rdLiOpen input,#rdCabMenu .rdLiT.rdLiOpen select{min-height:40px;font-size:16px}   /* 16px = iOS не зумира при фокус */
  .rdHndGrid{grid-template-columns:repeat(2,1fr)}
  .rdPpGrid{grid-template-columns:repeat(2,1fr) !important}
}

/* ===== ТЕЛЕФОН LANDSCAPE (14.09, Кристиан): при завъртане — 3D вляво, менюто на шкафа вдясно, тънък рейл, глава на един ред ===== */
@media (max-width:1000px) and (orientation:landscape) and (max-height:520px){
  html,body{overflow-x:hidden}
  body{margin-left:44px !important;padding-bottom:0 !important}
  #rdRail{position:fixed !important;left:0 !important;top:0 !important;bottom:0 !important;right:auto !important;width:44px !important;height:auto !important;flex-direction:column !important;justify-content:flex-start !important;align-items:center !important;padding:6px 0 !important;gap:2px !important;overflow-y:auto;overflow-x:hidden;scrollbar-width:none;z-index:1300}
  #rdRail::-webkit-scrollbar{display:none}
  #rdRail .rdlogo{display:none !important}
  #rdRail button{width:36px !important;height:36px !important;border-radius:9px !important;flex:none}
  #rdRail button svg{width:22px !important;height:22px !important}
  #rdSide,#rdSideTg,#rdSideThread,.rdRailThread,#rdRailThread,.rdThreadBar{display:none !important}
  /* главата: 40px, един ред, ⋯ за останалото */
  header{margin-left:0 !important;padding:0 8px !important;height:40px !important;min-height:0 !important;flex-wrap:nowrap !important;gap:8px !important;overflow:hidden}
  header.rdHdrOpen{height:auto !important;flex-wrap:wrap !important;padding:4px 8px !important}
  .projbar{flex-wrap:nowrap;gap:4px;margin-left:auto} .projbar button,.projbar .rdChip{padding:5px 7px;font-size:12px}
  header .rdTop[title^="Преименувай"],header .rdTop[title^="Изтрий"],header .rdTop[title^="Бекъп"],header .rdTop[title^="Възстанови"],header .rdTop[title^="Шаблони"],
  header #licBtn,header #themeBtn,header #lockBtn,header #shopBtn,header #redoBtn{display:none !important}
  header.rdHdrOpen .rdTop[title^="Преименувай"],header.rdHdrOpen .rdTop[title^="Изтрий"],header.rdHdrOpen .rdTop[title^="Бекъп"],header.rdHdrOpen .rdTop[title^="Възстанови"],header.rdHdrOpen .rdTop[title^="Шаблони"],
  header.rdHdrOpen #licBtn,header.rdHdrOpen #themeBtn,header.rdHdrOpen #lockBtn,header.rdHdrOpen #shopBtn,header.rdHdrOpen #redoBtn{display:inline-flex !important}
  #rdHdrMore{display:inline-flex !important;align-items:center;justify-content:center;min-width:32px;font-size:18px;line-height:1}
  header.rdHdrOpen #rdHdrMore{background:#e8b978;color:#1c2c44}
  header .rdSep{border-left:0 !important;margin-left:0 !important;padding-left:0 !important}
  /* колоните: 3D/съдържание вляво, менюто на шкафа фиксирано вдясно */
  .layout{flex-direction:row-reverse !important;padding:0 !important}
  .sidebar{position:fixed !important;top:40px !important;right:0 !important;bottom:0 !important;left:auto !important;width:300px !important;max-width:46vw !important;height:auto !important;overflow-y:auto !important;margin:0 !important;padding:0 0 12px !important;border-left:1px solid #d9dee6 !important;border-radius:0 !important;z-index:1100}
  body:not(.rdSbInPage):not(.rdSbClosed) .main{margin:0 min(300px,46vw) 0 0 !important}
  body.rdSbInPage .main{margin:0 !important} body.rdSbInPage #page-design{padding-right:min(300px,46vw)}
  .main{padding:6px !important;max-width:none}
  #rdCabMenu{width:auto !important}
  .preview-wrap,.preview-wrap.rdPrev{margin:0 !important;padding:0 !important;border-radius:10px !important}
  .preview-wrap.rdPrev .preview-box{padding:44px 0 0 !important}
  .rdBox3d,#rdVp{min-height:calc(100dvh - 40px - 12px - 44px) !important}
  .preview-wrap.rdPrev .rdPrevTools{left:auto !important;right:6px !important;top:6px !important;transform:none !important;width:40px !important}
  .preview-wrap.rdPrev .rdPrevTabs{left:8px !important;top:6px !important}
  .rdCine,#rdVpCube{display:none !important}
  #rdVp canvas,.rdBox3d canvas{touch-action:none}
  body.rdSbInPage #rdDocsBtn,body.rdSbInPage #demoBuyFab{right:calc(min(300px,46vw) + 10px) !important;bottom:10px !important}
  /* менюто на шкафа — плътно, но за пръст */
  .rdLiH{min-height:42px;font-size:13px} .rdLiH .r{max-width:52%}
  #rdCabMenu .rdLiT.rdLiOpen input,#rdCabMenu .rdLiT.rdLiOpen select{min-height:38px;font-size:16px}
  .rdHndGrid{grid-template-columns:repeat(2,1fr)} .rdPpGrid{grid-template-columns:repeat(2,1fr) !important}
  /* вътрешните страници: рейлът с разделите пак вляво, съдържанието вдясно (връща реда от тясната колона) */
  #rdBot,#rdHw,#rdNest,#rdWall,#rdPrice{flex-direction:row !important;gap:8px !important;align-items:stretch}
  #rdBotRail,#rdHwRail,#rdNestRail,#rdWallRail,#rdPriceRail{width:150px !important;flex:0 0 150px !important;flex-direction:column !important;flex-wrap:nowrap !important;overflow-y:auto !important;overflow-x:hidden !important;align-self:stretch !important;height:auto !important;max-height:calc(100dvh - 52px)}
  #rdBotRail .rbi,#rdHwRail .rbi,#rdNestRail .rbi,#rdWallRail .rbi,#rdPriceRail .rbi{white-space:normal;font-size:12px;padding:7px 8px}
  #rdBotGold,#rdHwGold,#rdNestGold,#rdWallGold,#rdPriceGold{margin-left:0}
  .rbSub{flex-basis:auto;flex-direction:column;border-left:2px solid #e8b978;margin:0 0 0 10px;padding:2px 0 4px 6px}
  #rdBot>*:not(#rdBotRail),#rdHw>*:not(#rdHwRail),#rdNest>*:not(#rdNestRail),#rdWall>*:not(#rdWallRail),#rdPrice>*:not(#rdPriceRail){min-height:0}
  .rdBotPanel.rdBotStats{grid-template-columns:repeat(3,1fr) !important}
  #labelsGrid{grid-template-columns:repeat(3,1fr) !important}
}
