/* Option Intelligence - phone layout (v1.17). Loaded after style.css on every page. Everything here is inside a media
   query, so the desktop layout is unchanged. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{-webkit-tap-highlight-color:transparent}
.m-nav,.m-sheet,.m-sheet-bg,.m-toggle,.m-offline{display:none}

@media (max-width:820px){
  :root{--nav-h:62px;--sat:env(safe-area-inset-top,0px);--sab:env(safe-area-inset-bottom,0px)}
  body{padding-bottom:calc(var(--nav-h) + var(--sab) + 12px);overscroll-behavior-y:contain}

  /* header: brand + status only (navigation moves to the bottom bar) */
  .topbar{padding:calc(10px + var(--sat)) 14px 10px;flex-direction:row;align-items:center;flex-wrap:wrap;gap:8px;position:sticky;top:0;z-index:50;background:var(--bg);border-bottom:1px solid var(--line)}
  .brand{font-size:16px;letter-spacing:1px}
  .topbar .sub{display:none}
  .top-actions{gap:6px;flex:1 1 100%;justify-content:flex-start;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;padding-bottom:2px}
  .top-actions::-webkit-scrollbar{display:none}
  .top-actions>*{flex:none}
  .top-actions>a.button{display:none}
  .pill{font-size:11px;padding:5px 8px}
  .user-chip{display:inline-flex;align-items:center;gap:6px}
  .user-chip>a{display:none}
  .user-chip button{padding:6px 10px;min-height:34px;font-size:12px}
  .save-state{font-size:11px;white-space:nowrap}

  main{padding:12px 10px}
  .panel{padding:12px;border-radius:12px}

  /* easier touch targets; 16px stops iOS zooming into fields */
  select,input,button,.button,textarea{font-size:16px;min-height:44px}
  input[type=checkbox],input[type=radio]{min-height:0;width:20px;height:20px}
  .chain-select{min-height:36px;font-size:13px}

  /* controls grid */
  .toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;align-items:end}
  .toolbar label{min-width:0}
  .toolbar select,.toolbar input{width:100%}
  .toolbar>button,.toolbar>.sub{grid-column:1/-1;margin:0}
  .toolbar>.sub{padding:0}
  .m-toggle{display:flex;align-items:center;justify-content:space-between;width:100%;margin:0 0 8px;background:var(--panel2);border-color:#354960;font-size:14px}
  .toolbar.m-collapsed label:nth-of-type(n+3),.toolbar.m-collapsed #testAlert,.toolbar.m-collapsed #alertChannels{display:none}

  .stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .stat .value{font-size:20px}
  .paper-stats,.derivatives-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .chart{height:320px}
  .chart-actions button{min-height:38px;font-size:13px}
  .chart-tools{gap:14px}
  .chart-tools label{min-height:36px}
  .section-head{flex-wrap:wrap}
  .paper-actions{width:100%}
  .paper-actions>button,.paper-actions>.button{flex:1}
  .table-wrap{max-height:none;-webkit-overflow-scrolling:touch}
  th,td{padding:9px 8px}
  .notice{font-size:12px}
  footer{padding-bottom:12px}
  .toast{bottom:calc(var(--nav-h) + var(--sab) + 12px)}

  /* bottom tab bar */
  .m-nav{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:900;height:calc(var(--nav-h) + var(--sab));padding:0 4px var(--sab);background:rgba(18,29,45,.97);border-top:1px solid var(--line);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}
  .m-nav a,.m-nav button{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;background:none;border:0;border-radius:10px;color:var(--muted);font:600 10.5px/1.1 inherit;font-family:inherit;text-decoration:none;padding:6px 2px;min-height:0;cursor:pointer}
  .m-nav svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .m-nav .on{color:var(--blue)}
  .m-nav .on svg{stroke:var(--blue)}

  /* "More" sheet */
  .m-sheet-bg{display:block;position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:960;opacity:0;pointer-events:none;transition:opacity .18s}
  .m-sheet{display:block;position:fixed;left:0;right:0;bottom:0;z-index:970;background:var(--panel);border-top:1px solid var(--line);border-radius:18px 18px 0 0;padding:14px 14px calc(14px + var(--sab));transform:translateY(105%);transition:transform .2s ease;max-height:80vh;overflow:auto}
  .m-open .m-sheet{transform:none}
  .m-open .m-sheet-bg{opacity:1;pointer-events:auto}
  .m-sheet h3{margin:2px 0 10px;font-size:15px}
  .m-sheet .m-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 4px;border-bottom:1px solid #233247;color:var(--text);text-decoration:none;font-size:15px;min-height:48px}
  .m-sheet .m-row small{display:block;color:var(--muted);font-size:12px;margin-top:2px}
  .m-sheet a.m-row::after{content:"›";color:var(--muted);font-size:20px}
  .m-sheet button.m-row{width:100%;background:none;border:0;border-bottom:1px solid #233247;border-radius:0;text-align:left;font-weight:500;font-size:15px}
  .m-switch{appearance:none;-webkit-appearance:none;display:block;box-sizing:border-box;width:46px;height:28px;min-height:0;padding:0;margin:0;border-radius:999px;background:#354960;border:0;position:relative;flex:none;transition:background .15s}
  .m-switch::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;transition:transform .15s}
  .m-select{flex:none;max-width:48%;min-height:36px;background:#0f1a2b;color:var(--text);border:1px solid #354960;border-radius:8px;padding:4px 8px;font-size:14px}
  .m-switch:checked{background:#1f9d6e}
  .m-switch:checked::after{transform:translateX(18px)}

  .m-offline{display:block;position:fixed;left:10px;right:10px;top:calc(var(--sat) + 6px);z-index:990;background:#2b2517;border:1px solid #66552c;color:#f5d995;border-radius:10px;padding:8px 12px;font-size:12px;text-align:center}
  .m-offline[hidden]{display:none}


  /* v1.18.6 - nothing may be wider than the screen. Grid/flex children default to min-width:auto, so one long value
     (a price, a contract name, a gate message) used to stretch a whole column past the edge of the phone. */
  html{overflow-x:hidden}
  body{max-width:100%}
  main,main>*,.panel,.section-head>*,.stat,.stats>*,.paper-grid>*,.confirm-grid>*,.dc-grid>*,.dc-final-grid>*,.dg-groups>*,.dc-two>*,.derivatives-grid>*,.deriv-card,.signal-box,.toolbar>*{min-width:0;max-width:100%}
  .confirm-grid,.dc-grid,.dc-final-grid,.dg-groups,.paper-grid,.dc-two{grid-template-columns:minmax(0,1fr)!important}
  .dc-big,.dg-big{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  #extraInd{grid-template-columns:minmax(0,1fr)}
  .dc-score,.dc-atr-grid>*{min-width:0}
  .dc-atr-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .sub,.notice,.gate-list li,.metric-list>*,.signal-value,.signal-box,.deriv-card,.stat,.item,h1,h2,h3,p,label,small{overflow-wrap:anywhere;word-break:normal}
  .gate-list{flex-wrap:wrap}
  .signal-value{font-size:clamp(20px,7vw,30px)}
  #lastPrice{font-size:clamp(20px,7vw,26px);white-space:normal;overflow-wrap:anywhere}
  .section-head,.chart-section-head,.chart-actions,.paper-actions,.capital-controls{flex-wrap:wrap;gap:8px}
  .capital-controls label{flex:1 1 140px;min-width:0}
  .chart-line-legend,.chart-tools{flex-wrap:wrap}
  .chart canvas,.chart svg,.chart>div{max-width:100%}
  .dg-toolbar input{width:100%}
  pre,code{white-space:pre-wrap;overflow-wrap:anywhere}

  /* Tables (v1.19). The v1.18.6 rule squeezed every table to the screen width with overflow-wrap:anywhere, so headers and
     numbers broke one letter per line ("Da / y", "P / RI / C / E", "-7 / 4. / 1 / 5"). Now:
     - wide data tables (option chain, live ticks...) keep whole words and numbers and scroll sideways INSIDE their box,
       first column pinned;
     - record-style tables (S/R map, weighted checks, patterns, signal log, daily results) are marked .cardify and become one
       card per row: label on the left, value on the right (mobile.js copies each column title into the cells). */
  .table-wrap{overflow-x:auto;max-width:100%;border-radius:10px;position:relative;scrollbar-width:thin}
  .table-wrap table{font-size:12px;width:max-content;min-width:100%}
  .table-wrap th,.table-wrap td{padding:7px 8px;white-space:nowrap;overflow-wrap:normal;word-break:normal;vertical-align:top}
  .table-wrap td.wrap{white-space:normal;min-width:140px;max-width:260px}
  .table-wrap th{font-size:10.5px;letter-spacing:.2px}
  .table-wrap td:first-child,.table-wrap th:first-child{position:sticky;left:0;z-index:1;background:var(--panel)}

  .table-wrap:has(table.cardify){overflow:visible;max-height:none}
  table.cardify{width:100%;min-width:0;white-space:normal;font-size:13px}
  table.cardify thead{display:none}
  table.cardify,table.cardify tbody{display:block;width:100%}
  table.cardify tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:12px;row-gap:2px;background:var(--panel2);border:1px solid var(--line);
    border-radius:10px;padding:9px 11px;margin:0 0 8px}
  table.cardify td{display:flex;flex-direction:column;gap:1px;position:static;padding:3px 0;border:0;text-align:left;white-space:normal;
    overflow-wrap:break-word;word-break:normal;min-width:0;max-width:none;background:none}
  table.cardify td::before{content:attr(data-label);color:var(--muted);font-size:10.5px;font-weight:600;letter-spacing:.2px}
  table.cardify td:first-child{grid-column:1/-1;flex-direction:row;align-items:baseline;gap:8px;font-weight:800;font-size:14px;
    border-bottom:1px solid var(--line);padding-bottom:6px;margin-bottom:4px;position:static;background:none}
  table.cardify td:first-child::before{font-size:10.5px}
  table.cardify td.wide,table.cardify td:last-child:not(:nth-child(2n)){grid-column:1/-1}
  table.cardify td:empty,table.cardify td.blank{display:none}
  table.cardify td.empty{grid-column:1/-1;text-align:center}
  table.cardify td.empty::before{display:none}
  table.cardify tr.sr-missing td:not(:first-child):not(:last-child){display:none}
  table.cardify tr.sr-price{background:#1a2f4a;border-color:#2e4e70}
  table.cardify tr.sr-support td:first-child{color:var(--green)}
  table.cardify tr.sr-resistance td:first-child{color:var(--red)}

  /* stat cards: long notes (e.g. the regime evidence) are clamped to 3 lines; tap the card to read all of it */
  .stat .sub{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
  .stat.open .sub{-webkit-line-clamp:unset;display:block}
  .stat{cursor:pointer}
  .top-actions{flex-wrap:wrap}
  .bp-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}

  /* account + login */
  .account-main{padding-bottom:20px}
  .auth-wrap{padding:calc(24px + var(--sat)) 14px 24px}
}

@media (max-width:520px){
  .stat .value{font-size:18px}
  .toolbar{gap:8px}
  .chart{height:300px}
}

/* installed app: no browser chrome to account for */
@media (display-mode:standalone) and (max-width:820px){
  .topbar{padding-top:calc(10px + var(--sat))}
}
