/* =====================================================================
   Drex's Thoughts — MOBILE 2026-11-30
   Кнопка «назад», крестики у всех окон, вырез экрана iPhone,
   границы графика и раскладка под каждое устройство.
   Мобильная раскладка: ширина до 860px ИЛИ телефон боком (высота до 500px).
   Префикс :root:not(#dxm) поднимает вес правил над старыми !important.
   ===================================================================== */

/* ---------- общие кнопки модуля ---------- */
.dxm-back{display:none}
.dxm-x{flex:none;display:inline-grid;place-items:center;width:40px;height:40px;padding:0;border-radius:50%;border:1px solid var(--dk-edge,var(--line));background:var(--dk-chip,rgba(255,255,255,.06));color:var(--ink);cursor:pointer;-webkit-tap-highlight-color:transparent;transition:transform .18s cubic-bezier(.2,.8,.2,1),background .2s,border-color .2s,box-shadow .2s}
.dxm-x svg{width:18px;height:18px;pointer-events:none}
.dxm-x:hover{border-color:var(--dk-edge-hi,var(--acc));background:rgba(var(--dk-a-rgb,91,140,255),.14);box-shadow:0 0 0 3px rgba(var(--dk-a-rgb,91,140,255),.1)}
.dxm-x:active{transform:scale(.88)}
.dxm-x:focus-visible,.dxm-back:focus-visible{outline:2px solid var(--dk-a,var(--acc));outline-offset:2px}
.dxm-x-sm{width:32px;height:32px}
.dxm-x-sm svg{width:15px;height:15px}

/* ---------- окно графика: шапка (все экраны) ---------- */
:root:not(#dxm) .chart-modal-head{gap:12px}
:root:not(#dxm) .chart-modal-head b{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
:root:not(#dxm) .chart-modal-acts{display:flex;align-items:center;gap:8px;flex:none}
:root:not(#dxm) .chart-modal-x.cm-tv,:root:not(#dxm) .chart-modal-x.cm-close{display:inline-flex;align-items:center;gap:7px;white-space:nowrap}
:root:not(#dxm) .chart-modal-x.cm-tv[hidden]{display:none!important}
:root:not(#dxm) .cm-close{color:var(--ink)}
:root:not(#dxm) .cm-close svg,:root:not(#dxm) .cm-tv svg{flex:none}

/* панель уведомлений: плотный фон и нормальная кнопка «Показать всё» (её портил общий стиль кнопок шапки) */
html[data-drex-theme^="desk"]:not(#dxm) .bell-panel{background-color:rgb(var(--dk-bg-rgb,8,12,22))!important;-webkit-backdrop-filter:blur(22px) saturate(1.4);backdrop-filter:blur(22px) saturate(1.4)}
:root:not(#dxm) .top .bell-panel-all{display:block!important;width:100%!important;height:auto!important;min-width:0!important;margin:0!important;padding:12px!important;border:0!important;border-top:1px solid var(--dk-edge,var(--line))!important;border-radius:0!important;background:rgba(var(--dk-a-rgb,91,140,255),.08)!important;color:var(--dk-a2,var(--acc))!important;font-size:12.5px!important;font-weight:650!important;white-space:nowrap}
:root:not(#dxm) .top .bell-panel-all:hover{background:rgba(var(--dk-a-rgb,91,140,255),.18)!important}
:root:not(#dxm) .top .bell-panel-head .dxm-x{width:32px!important;min-width:32px!important;height:32px!important;border-radius:50%!important}
:root:not(#dxm) .bell-panel-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding-top:9px!important;padding-bottom:9px!important}

/* подсказки графика: мышь на компьютере, пальцы на телефоне */
.lc-hint-touch{display:none}
@media (pointer:coarse){.lc-hint-touch{display:block}.lc-hint-desk{display:none}}

/* жест «назад» от левого края (приложение на iPhone) */
#dxm-edge{position:fixed;left:-56px;top:50%;z-index:2147483000;width:46px;height:46px;margin-top:-23px;border-radius:50%;display:grid;place-items:center;pointer-events:none;color:#fff;background:rgba(var(--dk-a-rgb,91,140,255),.92);box-shadow:0 10px 30px -8px rgba(var(--dk-a-rgb,91,140,255),.9);opacity:0;transition:opacity .15s}
#dxm-edge svg{width:22px;height:22px}
#dxm-edge.on{opacity:1}
#dxm-edge.go{background:var(--dk-grad-btn,var(--acc))}

/* полоса под вырезом экрана (только в приложении с вырезом) */
#dxm-safe{display:none}

/* ======================================================================
   МОБИЛЬНАЯ РАСКЛАДКА
   ====================================================================== */
@media (max-width:860px),(max-height:500px) and (max-width:1024px) and (pointer:coarse){

  /* --- шапка: логотип прокручивается, строка раздела липнет сверху --- */
  :root:not(#dxm) body aside{position:relative!important;top:auto!important;padding-top:calc(12px + env(safe-area-inset-top,0px))!important;padding-left:calc(14px + env(safe-area-inset-left,0px))!important;padding-right:calc(14px + env(safe-area-inset-right,0px))!important}
  :root:not(#dxm) body .col>.top{position:-webkit-sticky!important;position:sticky!important;top:calc(env(safe-area-inset-top,0px) + 6px)!important;z-index:45!important;margin-left:calc(10px + env(safe-area-inset-left,0px))!important;margin-right:calc(10px + env(safe-area-inset-right,0px))!important;gap:6px!important;transition:box-shadow .25s ease}
  :root:not(#dxm) body.dxm-stuck .col>.top{box-shadow:0 14px 34px -14px rgba(0,0,0,.75)}
  #dxm-safe{display:block;position:fixed;left:0;right:0;top:0;height:calc(env(safe-area-inset-top,0px) + 6px);z-index:44;pointer-events:none;opacity:0;transition:opacity .2s ease;background:linear-gradient(180deg,rgba(var(--dk-bg-rgb,6,8,14),.96),rgba(var(--dk-bg-rgb,6,8,14),.82));-webkit-backdrop-filter:blur(18px) saturate(1.4);backdrop-filter:blur(18px) saturate(1.4)}
  body.dxm-stuck #dxm-safe{opacity:1}
  body.locked #dxm-safe{display:none}

  /* --- кнопка «назад» --- */
  :root:not(#dxm) .top .dxm-back{order:-1!important;flex:none!important;width:38px;height:38px;min-width:38px;padding:0!important;place-items:center;border-radius:13px;border:1px solid var(--dk-edge,var(--line));background:var(--dk-chip,rgba(255,255,255,.06));color:var(--ink)!important;cursor:pointer;-webkit-tap-highlight-color:transparent}
  :root:not(#dxm).dxm-sub .top .dxm-back{display:grid;animation:dxmBackIn .32s cubic-bezier(.2,.8,.2,1) both}
  :root:not(#dxm) .top .dxm-back svg{width:20px;height:20px;transition:transform .2s cubic-bezier(.2,.8,.2,1)}
  :root:not(#dxm) .top .dxm-back:active{transform:scale(.88)}
  :root:not(#dxm) .top .dxm-back:active svg{transform:translateX(-2px)}
  @keyframes dxmBackIn{from{opacity:0;transform:translateX(-8px) scale(.9)}to{opacity:1;transform:none}}
  :root:not(#dxm).dxm-sub .top #ttl{margin-left:2px}

  /* --- остальные полосы и контент не залезают под вырез сбоку (телефон боком) --- */
  :root:not(#dxm) body #dxtape{margin-left:calc(10px + env(safe-area-inset-left,0px))!important;margin-right:calc(10px + env(safe-area-inset-right,0px))!important}
  :root:not(#dxm) body main#v{padding-left:calc(10px + env(safe-area-inset-left,0px))!important;padding-right:calc(10px + env(safe-area-inset-right,0px))!important;padding-bottom:calc(112px + env(safe-area-inset-bottom,0px))!important}
  :root:not(#dxm) body #bnav{left:calc(10px + env(safe-area-inset-left,0px))!important;right:calc(10px + env(safe-area-inset-right,0px))!important}

  /* --- окно графика во весь экран, с учётом выреза и «полоски домой» --- */
  :root:not(#dxm) .chart-modal{padding:0!important;align-items:stretch!important}
  :root:not(#dxm) .chart-modal-inner{width:100%!important;height:100vh!important;height:100dvh!important;max-height:none!important;border-radius:0!important;border:0!important;padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}
  :root:not(#dxm) .chart-modal-head{padding:calc(8px + env(safe-area-inset-top,0px)) 10px 8px 16px!important;min-height:56px}
  :root:not(#dxm) .chart-modal-head b{font-size:15.5px!important}
  :root:not(#dxm) .chart-modal-x.cm-tv,:root:not(#dxm) .chart-modal-x.cm-close{width:42px;height:42px;padding:0!important;justify-content:center;border-radius:50%!important;font-size:0!important}
  :root:not(#dxm) .chart-modal-x.cm-tv span,:root:not(#dxm) .chart-modal-x.cm-close span{display:none}
  :root:not(#dxm) .chart-modal-x.cm-close{background:rgba(var(--dk-a-rgb,91,140,255),.16)!important;border-color:rgba(var(--dk-a-rgb,91,140,255),.45)!important}
  :root:not(#dxm) .chart-modal-x.cm-close:active,:root:not(#dxm) .chart-modal-x.cm-tv:active{transform:scale(.88)}
  :root:not(#dxm) .chart-modal-body{padding-bottom:env(safe-area-inset-bottom,0px)}

  /* --- график: лента инструментов листается вбок, ничего не обрезается --- */
  :root:not(#dxm) .lc-tools{overflow-x:auto!important;overflow-y:hidden!important;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;scrollbar-width:none;flex-wrap:nowrap!important;-webkit-mask-image:linear-gradient(90deg,#000 0,#000 calc(100% - 26px),transparent);mask-image:linear-gradient(90deg,#000 0,#000 calc(100% - 26px),transparent);padding-right:26px!important}
  :root:not(#dxm) .lc-tools.dxm-end{-webkit-mask-image:none;mask-image:none}
  :root:not(#dxm) .lc-tools::-webkit-scrollbar{display:none}
  :root:not(#dxm) .lc-tools>*{flex:none!important}
  /* плашка текущей цены не упирается в край */
  :root:not(#dxm) .lc-ax{right:3px!important;width:58px!important}
  /* график внутри карточек не касается скруглённых углов */
  :root:not(#dxm) .lc-tab .lc-box,:root:not(#dxm) .eco-widget .lc-box{margin:0 6px 6px!important;border-radius:0 0 12px 12px}
  :root:not(#dxm) .lc-tab{height:min(72vh,640px)!important;min-height:420px}
  /* «Терминал»: график с отступом от рамки, плашка цены целиком внутри */
  :root:not(#dxm) .tm-chart{margin:0 6px!important}

  /* --- меню «Ещё»: заголовок и крестик --- */
  :root:not(#dxm) #msheet .sp{max-height:calc(100vh - env(safe-area-inset-top,0px) - 24px)!important;max-height:calc(100dvh - env(safe-area-inset-top,0px) - 24px)!important;padding-top:6px!important;padding-left:calc(16px + env(safe-area-inset-left,0px))!important;padding-right:calc(16px + env(safe-area-inset-right,0px))!important}
  #msheet .dxm-shead{position:-webkit-sticky;position:sticky;top:0;z-index:3;display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 -16px 4px;padding:8px 14px 12px 18px;background:linear-gradient(180deg,var(--side,var(--card,#0c111c)) 72%,transparent)}
  #msheet .dxm-shead b{font:700 17px/1.2 var(--sans,inherit);letter-spacing:-.01em;color:var(--ink)}
  #msheet .dxm-shead small{display:block;margin-top:2px;font-size:11.5px;font-weight:500;color:var(--mut)}

  /* --- настройки (шестерёнка): шапка и крестик ниже выреза --- */
  :root:not(#dxm) #eco-studio .eco-studio-panel{padding-top:env(safe-area-inset-top,0px)!important;padding-bottom:env(safe-area-inset-bottom,0px)!important}
  :root:not(#dxm) #eco-studio .eco-x{width:42px!important;height:42px!important;border-radius:50%!important;font-size:22px!important;display:grid!important;place-items:center!important}

  /* --- быстрый поиск: крестик вместо клавиши Esc --- */
  :root:not(#dxm) #dxk{padding-top:calc(14px + env(safe-area-inset-top,0px))!important}
  :root:not(#dxm) #dxk .dxk-top kbd{display:none!important}
  :root:not(#dxm) #dxk .dxk-foot{display:none!important}
  #dxk .dxk-top .dxm-x{margin-left:4px}

  /* --- уведомления и палитра: крестик в шапке --- */
  .bell-panel-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
  .dk-pop-h{display:flex;align-items:center;gap:10px}
  .dk-pop-h small{margin-left:auto}
  :root:not(#dxm) .dk-pop{max-height:calc(100dvh - 140px - env(safe-area-inset-bottom,0px));overflow-y:auto;overscroll-behavior:contain}

  /* --- соцсети и окна снизу: не под вырезом и не под «полоской домой» --- */
  :root:not(#dxm) #socm{padding:calc(20px + env(safe-area-inset-top,0px)) calc(16px + env(safe-area-inset-right,0px)) calc(20px + env(safe-area-inset-bottom,0px)) calc(16px + env(safe-area-inset-left,0px))!important}
  :root:not(#dxm) #socm .sp{max-height:100%;overflow-y:auto}
}

/* ---------- узкие экраны: iPhone SE / mini, компактные Android, Galaxy Fold ---------- */
@media (max-width:400px){
  :root:not(#dxm) body .col>.top{gap:4px!important;padding:7px 7px 7px 11px!important}
  :root:not(#dxm) body .top button,:root:not(#dxm) body #dxk-btn,:root:not(#dxm) body #eco-settings-trigger,:root:not(#dxm) body #bell,:root:not(#dxm) body .dk-pal-btn,:root:not(#dxm) body .top #tzt,:root:not(#dxm) .top .dxm-back{width:35px!important;min-width:35px!important;height:35px!important;border-radius:12px!important}
  :root:not(#dxm) body .top #tzt{background-size:16px!important}
  :root:not(#dxm) body #ttl{font-size:16.5px!important}
  :root:not(#dxm) body aside .brand .av{width:36px!important;height:36px!important}
}
@media (max-width:360px){
  /* в разделах прячем выбор часового пояса — он остаётся на главной и в календарных разделах */
  :root:not(#dxm).dxm-sub:not(.dxm-tz) body .top #tzt{display:none!important}
  :root:not(#dxm) body #ttl{font-size:15.5px!important}
  :root:not(#dxm) body #bnav button{font-size:10px!important}
}

/* ---------- телефон боком: всё компактнее, контенту больше места ---------- */
@media (max-height:500px) and (max-width:1024px) and (pointer:coarse){
  :root:not(#dxm) body aside{padding-top:calc(6px + env(safe-area-inset-top,0px))!important;padding-bottom:4px!important}
  :root:not(#dxm) body aside .brand{padding:2px 6px 2px!important}
  :root:not(#dxm) body aside .brand .av{width:32px!important;height:32px!important}
  :root:not(#dxm) body .col>.top{min-height:46px!important;padding-top:4px!important;padding-bottom:4px!important;margin-top:4px!important;top:4px!important}
  :root:not(#dxm) body .top button,:root:not(#dxm) body #dxk-btn,:root:not(#dxm) body #eco-settings-trigger,:root:not(#dxm) body #bell,:root:not(#dxm) body .dk-pal-btn,:root:not(#dxm) body .top #tzt,:root:not(#dxm) .top .dxm-back{height:34px!important;min-width:34px!important}
  :root:not(#dxm) body #dxtape{height:34px!important;margin-top:6px!important}
  /* нижнее меню в одну строку: иконка и подпись рядом */
  :root:not(#dxm) body #bnav{bottom:calc(6px + env(safe-area-inset-bottom,0px))!important;padding-top:3px!important;padding-bottom:3px!important}
  :root:not(#dxm) body #bnav button{flex-direction:row!important;gap:6px!important;min-height:40px!important;padding:3px 6px!important}
  :root:not(#dxm) body #bnav button svg{width:30px!important;height:24px!important;padding:3px 7px!important}
  :root:not(#dxm) body main#v{padding-top:12px!important;padding-bottom:calc(72px + env(safe-area-inset-bottom,0px))!important}
  :root:not(#dxm) .lc-tab{height:calc(100dvh - 120px)!important;min-height:280px!important}
  :root:not(#dxm) .chart-modal-head{min-height:46px;padding-top:6px!important;padding-bottom:6px!important}
  :root:not(#dxm) .chart-modal-x.cm-tv,:root:not(#dxm) .chart-modal-x.cm-close{width:36px;height:36px}
  :root:not(#dxm) #msheet .sp{max-height:calc(100dvh - 16px)!important}
}

/* ---------- планшеты в портрете (iPad mini, iPad, Android-планшеты) ---------- */
@media (min-width:600px) and (max-width:860px){
  :root:not(#dxm) body main#v{padding-left:calc(18px + env(safe-area-inset-left,0px))!important;padding-right:calc(18px + env(safe-area-inset-right,0px))!important}
  :root:not(#dxm) body #bnav{left:max(20px,calc(50% - 290px))!important;right:max(20px,calc(50% - 290px))!important}
  :root:not(#dxm) #msheet .sp{left:max(0px,calc(50% - 330px))!important;right:max(0px,calc(50% - 330px))!important;border-radius:24px 24px 0 0}
}

/* ---------- меньше движения ---------- */
@media (prefers-reduced-motion:reduce){
  .top .dxm-back{animation:none!important}
  #dxm-edge{transition:none}
}

/* ======================================================================
   КОМПАКТНО НА ТЕЛЕФОНЕ (30.11, вторая правка)
   ====================================================================== */
@media (max-width:860px),(max-height:500px) and (max-width:1024px) and (pointer:coarse){
  /* раздел открывается как экран приложения: без большого логотипа, сразу шапка с крестиком */
  :root:not(#dxm).dxm-sub body aside{display:none!important}
  :root:not(#dxm).dxm-sub body .col>.top{margin-top:calc(env(safe-area-inset-top,0px) + 8px)!important}
  /* прилипшая шапка плотная — текст страницы под ней не просвечивает */
  :root:not(#dxm) body.dxm-stuck .col>.top{background:linear-gradient(180deg,rgba(var(--dk-bg-rgb,8,12,22),.96),rgba(var(--dk-bg-rgb,8,12,22),.9))!important}
  /* крестик «Закрыть раздел» слегка подсвечен, чтобы его сразу находили */
  :root:not(#dxm) .top .dxm-back{background:rgba(var(--dk-a-rgb,91,140,255),.14)!important;border-color:rgba(var(--dk-a-rgb,91,140,255),.42)!important}
  :root:not(#dxm) .top .dxm-back svg{width:18px;height:18px}
  :root:not(#dxm) .top .dxm-back:active svg{transform:rotate(90deg) scale(.9)}

  /* баннер ближайшего события — в одну-две строки */
  :root:not(#dxm) body #bn{width:auto!important;max-width:none!important;margin:10px calc(10px + env(safe-area-inset-right,0px)) 0 calc(10px + env(safe-area-inset-left,0px))!important;padding:9px 12px!important;font-size:12.5px!important;line-height:1.4!important;border-radius:14px!important}

  /* панель над графиком в два ряда вместо четырёх */
  :root:not(#dxm) .lc-top{padding:8px 10px!important;gap:6px!important;flex-wrap:wrap!important;justify-content:flex-start!important}
  :root:not(#dxm) .lc-top>.lc-l,:root:not(#dxm) .lc-top>.lc-r{display:contents!important}
  :root:not(#dxm) .lc-top .cp-btn,:root:not(#dxm) .lc-top .lc-tfbtn,:root:not(#dxm) .lc-top .lc-ab{height:31px!important;min-height:31px!important;padding:0 11px!important;font-size:12.5px!important;border-radius:999px!important;gap:5px}
  :root:not(#dxm) .lc-top .lc-ab[data-lca="reset"],:root:not(#dxm) .lc-top .lc-ab[data-lca="clear"]{position:relative;width:34px!important;min-width:34px!important;padding:0!important;font-size:0!important;color:var(--mut)}
  :root:not(#dxm) .lc-top .lc-ab[data-lca="reset"]::before,:root:not(#dxm) .lc-top .lc-ab[data-lca="clear"]::before{content:"";position:absolute;left:50%;top:50%;width:16px;height:16px;margin:-8px 0 0 -8px;background:currentColor;-webkit-mask:var(--dxm-ico) center/16px no-repeat;mask:var(--dxm-ico) center/16px no-repeat}
  :root:not(#dxm) .lc-top .lc-ab[data-lca="reset"]{--dxm-ico:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E")}
  :root:not(#dxm) .lc-top .lc-ab[data-lca="clear"]{--dxm-ico:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6'/%3E%3C/svg%3E")}
  :root:not(#dxm) .lc-sub{padding:5px 12px!important;font-size:11px!important;min-height:0!important}
  :root:not(#dxm) .lc-tools{padding-top:4px!important;padding-bottom:4px!important}
  :root:not(#dxm) .lc-tools button{width:34px!important;height:34px!important}
}
@media (max-width:860px),(max-height:500px) and (max-width:1024px) and (pointer:coarse){
  /* в разделах полоса под вырезом видна сразу (логотипа сверху нет) */
  :root:not(#dxm).dxm-sub body #dxm-safe{opacity:1}
}
