/* ChartEdgeIndia — phone layout (≤760px). Loaded after app.css so these rules win on small screens. */
.msyms, .mrow, .st-sum, .m-layers { display: none; }
.savebar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px;
           padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 -6px 18px rgba(0,0,0,.3); }
.savebar[hidden] { display: none; }
.savebar.dirty { border-color: var(--warn); }
.savebar.dirty .small { color: var(--warn); font-weight: 600; }
.savebar.dirty { flex-wrap: wrap; } .savebar .row { flex-wrap: nowrap; margin-left: auto; }      /* Discard + Save stay side by side; on a phone they go under "Unsaved changes" */
.set-nav a.on { color: var(--fg); border-color: var(--accent); }
/* update / install bar (pwa.js) and the iPhone guide */
.appbar { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 75; display: flex; align-items: center;
          gap: 10px; flex-wrap: wrap; max-width: min(640px, calc(100vw - 16px)); padding: 10px 12px; background: var(--panel); border: 1px solid var(--accent);
          border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13px; }
.appbar[hidden] { display: none; }
.netbar { position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; z-index: 90; padding: 8px 12px; text-align: center; font-size: 13px; font-weight: 600;
          background: var(--down); color: #fff; }
.netbar[hidden] { display: none; }
.ptr { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, 0); z-index: 70; width: 36px; height: 36px; border-radius: 50%;
       display: flex; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); font-size: 18px; color: var(--muted); }
.ptr.ready { color: var(--accent); border-color: var(--accent); }
.ptr[hidden] { display: none; }
@media (max-width: 760px) {
  dialog.confirm.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; border-bottom: 0;
                         padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  dialog.confirm.sheet .row { position: sticky; bottom: 0; background: inherit; }
  dialog.confirm.sheet { border-color: var(--line); }                      /* red is for real orders only */
  dialog.confirm.sheet .row .btn { flex: 1; min-height: 44px; }
}
.appbar span { flex: 1 1 200px; }
.ios-guide { margin: 8px 0; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: 10px; }
.ios-guide ol { margin: 6px 0 6px 18px; padding: 0; }
@media (max-width: 760px) { .appbar { left: 8px; right: 8px; transform: none; max-width: none; top: calc(52px + env(safe-area-inset-top)); } }
.st-pop[hidden] { display: none; }
.ai-sect p { margin: 0; }
.tgshare-sheet { top: 56px; bottom: auto; }

@media (max-width: 760px) {
  /* iOS zooms into any field smaller than 16px when you tap it */
  input, select, textarea { font-size: 16px !important; }

  /* ---- top bar: brand + page menu on one line, status as one swipeable strip, kill switch always visible ---- */
  .topbar { flex-wrap: wrap; gap: 6px; padding-bottom: 6px; }
  .topbar .brand { flex: 1 1 auto; min-width: 0; }
  .status { order: 3; width: 100%; flex: 1 1 100%; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
            -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 6px; padding-bottom: 2px; }
  .status::-webkit-scrollbar { display: none; }
  .status > * { flex: none; }
  .status .iconbtn[href="#settings"] { display: none; }          /* Settings is in the bottom bar */
  #st-auto, #st-tg, #st-clock, .palbtn { display: none !important; }
  #kill { position: sticky; right: 0; order: 99; box-shadow: -10px 0 10px var(--panel); padding: 4px 10px; font-size: 12px; }
  #logout { order: 98; display: inline-flex !important; }

  /* ---- terminal: symbol chips, chart first, then side panel and watchlist ---- */
  .terminal { display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .terminal > .chartp { order: 1; }
  .terminal > .side { order: 2; }
  .terminal > .watch { order: 3; }
  .terminal > .split { display: none; }
  .terminal.hide-watch > .watch, .terminal.hide-side > .side { display: flex; }
  .mtools { display: flex; gap: 8px; padding: 8px 10px 0; }
  .mtools .btn { flex: 1; padding: 8px 10px; font-size: 13px; }
  .terminal.m-watch > .watch { order: 0; }
  .msyms { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .msyms::-webkit-scrollbar { display: none; }
  .msyms button { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 92px; padding: 6px 10px;
                  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); font: inherit; text-align: left; }
  .msyms button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  .msyms b { font-size: 12.5px; } .msyms small { font-family: var(--mono); font-size: 11px; }
  .msyms .sig { color: var(--warn); font-size: 11px; font-weight: 600; }
  .chart-h { gap: 6px; padding: 6px 10px; }
  .chart-h .sym { width: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
  .chart-h .sym #c-contract { font-size: 11px; }
  .chart-h .tf { flex: 1; display: flex; } .chart-h .tf button { flex: 1; padding: 6px 0; min-height: 34px; }
  .chart-h .tools #tog-watch, .chart-h .tools #tog-side { display: none; }
  .overlays-bar { padding: 4px 8px; }
  .overlays { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 12px; padding: 2px 0; align-items: center; }
  .overlays::-webkit-scrollbar { display: none; }
  .overlays > * { flex: none; }
  .overlays label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; min-height: 32px; }
  .ind-menu { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(64px + env(safe-area-inset-bottom)); width: auto;
              max-height: 60vh; overflow-y: auto; z-index: 60; }
  .chart { flex: none; height: max(300px, 52vh); min-height: 0; }
  .osc .pane { height: 100px; }
  .legend { font-size: 10px; gap: 6px; max-width: calc(100% - 78px); flex-wrap: wrap; }
  .gl-group { overflow-x: auto; } .gl-group table { table-layout: auto; } .gl-group td { white-space: nowrap; }
  .st-rule { overflow: hidden; }
  .chart-foot { display: none; }
  .side { max-height: none; }
  .side-tabs { overflow-x: auto; scrollbar-width: none; } .side-tabs button { flex: none; padding: 10px 12px; }
  .watch .watch-list { max-height: none; }
  .watch-head, .watch-list li { grid-template-columns: 1.4fr 1fr .8fr .8fr; }
  /* the × sits on its own line under the name: a 36px-high tap target that reaches into the gap above and the row's padding below, so the row barely grows */
  .watch-list .rm { visibility: visible; min-height: 36px; margin: -6px 0 calc(-1 * var(--pad)); }

  /* ---- pages ---- */
  .page { padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
  .page-h { flex-wrap: wrap; } .page-h h2 { font-size: 18px; }
  .card { min-width: 0; }
  .cards, .cards.wide { grid-template-columns: 1fr !important; }
  .grid { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .grid th, .grid td { white-space: nowrap; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gl-group, .gl-top > * { min-width: 0; }
  .seg { flex-wrap: wrap; } .seg button { min-height: 32px; }
  .btn, .btn.tiny { min-height: 32px; }
  .row.wrap > input, .row.wrap > select { flex: 1 1 140px; }
  #gp-api-hash, #gp-q, #gp-phone, #gp-pass { width: 100%; }
  .st-passed { grid-template-columns: 1fr; }
  .st-tbl { display: block; overflow-x: auto; }
  .bottomnav { position: relative; z-index: 30; }
  .bottomnav a { padding: 6px 4px 5px; font-size: 12px; }
  dialog { max-width: calc(100vw - 24px); }
  .toasts { left: 12px; right: 12px; transform: none; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast-item { width: 100%; text-align: center; font-size: 13px; padding: 7px 12px; }
  .tgshare-sheet { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); max-height: 70vh; overflow-y: auto; }
  .tg-msg { font-size: 16px; }
}

/* ---- 27 Nov phone fixes: one-row top bar, chart that fills the screen, layers button, tables as cards, bigger taps ---- */
@media (max-width: 760px) {
  .topbar { flex-wrap: nowrap; gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .topbar .brand .wm { display: none; }                         /* logo only */
  .topbar .brand { flex: none; }
  .status { order: 0; width: auto; flex: 1 1 auto; min-width: 0; overflow: visible; padding: 0; justify-content: flex-end; }
  .status > .pill, #st-err, .status .iconbtn[href="#settings"], #logout { display: none !important; }
  .st-sum { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; padding: 6px 10px; min-height: 34px; border: 1px solid var(--line);
            border-radius: 999px; background: var(--bg); color: var(--fg); font: inherit; font-size: 12px; font-weight: 600; }
  .st-sum .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--up); flex: none; }
  .st-sum[data-lvl="warn"] .dot { background: var(--warn); } .st-sum[data-lvl="bad"] .dot { background: var(--down); }
  .st-pop { position: fixed; left: 8px; right: 8px; top: calc(52px + env(safe-area-inset-top)); z-index: 70; background: var(--panel); border: 1px solid var(--line);
            border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
  .st-pop .st-row { display: flex; align-items: center; gap: 8px; } .st-pop .st-row small { flex: 1; }
  .st-pop .row { display: flex; gap: 8px; flex-wrap: wrap; }
  .st-pop a.btn { text-decoration: none; display: inline-flex; align-items: center; }
  #kill { position: static; box-shadow: none; padding: 6px 10px; }
  .tg-top { min-width: 36px; }
  .more-btn { padding: 8px 6px; }
  .topbar .more-wrap { order: 5; }

  .mrow { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
  .mrow .mtools { display: flex; gap: 6px; padding: 0; flex: none; }
  .mrow .mtools .btn { flex: none; width: 38px; min-height: 38px; padding: 0; font-size: 16px; }
  .mrow .msyms { flex: 1; min-width: 0; padding: 0; border: 0; }
  .msyms button { min-width: 0; padding: 4px 9px; gap: 0; border-radius: 9px; }
  .msyms b { font-size: 12px; } .msyms small { font-size: 11px; }
  .msyms .sig { font-size: 10.5px; }

  .chartp > .mrow { order: 0; } .chartp > .chart-h { order: 1; } .chartp > .overlays-bar { order: 2; }
  .chartp > .chart-area { order: 3; } .chartp > .rstrip { order: 3; padding: 4px 10px 2px; } .rs-legend { display: none; }
  .rs-info { white-space: normal; font-size: 10.5px; } .rs-foot { align-items: flex-start; } .chartp > .hotbar { order: 4; border-top: 1px solid var(--line); } .chartp > .chart-foot { order: 5; }
  .chartp > .overlays-bar { display: none; }
  .chartp.show-ov > .overlays-bar { display: flex; }
  .chartp.show-ov .overlays { flex-wrap: wrap; overflow: visible; }
  .m-layers { display: inline-flex; align-items: center; justify-content: center; }
  .chart-h .tools .btn { display: inline-flex; align-items: center; justify-content: center; }
  .chart-h { padding: 4px 8px; gap: 4px; }
  .chart-h .sym { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .chart-h .sym #c-contract { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; }
  .chart-h .sym #c-price, .chart-h .sym #c-chg { flex: none; }
  .chart-h .tf button { min-height: 36px; }

  /* bigger tap targets */
  .btn.tiny, .chip, .seg button, .side-tabs button { min-height: 38px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  label.check { min-height: 36px; display: flex; align-items: center; gap: 8px; }

  /* wide tables as cards (mobile.js labels each cell with its column) */
  table.mcard, .grid.mcard { display: block; overflow: visible; border: 0; }
  table.mcard thead { display: none; }
  table.mcard tbody { display: flex; flex-direction: column; gap: 8px; }
  table.mcard tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--panel); }
  table.mcard td:first-child, table.mcard td[colspan] { grid-column: 1 / -1; }
  table.mcard td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; white-space: normal !important; text-align: right; }
  table.mcard td::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; flex: none; max-width: 45%; }
  table.mcard td[data-l=""]::before { content: none; }
  table.mcard td:first-child { font-weight: 600; }
  .ck-tw:has(table.mcard) { overflow: visible; }
}

/* phone turned sideways: chart only (turn it back upright for the menus) */
@media (orientation: landscape) and (max-height: 500px) {
  .topbar, .bottomnav, .mrow, .hotbar, .chartp > .overlays-bar, .chart-h .sym, .chart-foot, .tg-top { display: none !important; }
  .terminal { display: flex !important; flex-direction: column; overflow-y: auto; }
  .terminal > .panel { flex: none; overflow: visible; }
  .terminal > .watch, .terminal > .split { display: none !important; }
  .terminal > .chartp { order: 1; } .terminal > .side { order: 2; max-height: none; }
  .chart-h { padding: 2px 8px; flex-wrap: nowrap; }
  .chart-h .tf button { min-height: 32px; padding: 4px 10px; }
  .osc .pane { height: 64px; }
}

/* ---- 27 Nov (2): Settings in sections, 12-point minimum text on phones ---- */
@media (max-width: 760px) {
  #view-settings.m-sections .cards > .card { display: none; }
  #view-settings.m-sections .cards > .card.m-on { display: block; }
  #view-settings .set-nav { position: sticky; top: -12px; z-index: 15; background: var(--bg); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
                            margin: 0 -12px 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  #view-settings .set-nav::-webkit-scrollbar { display: none; }
  #view-settings .set-nav a { flex: none; padding: 8px 12px; font-size: 13px; }
  .savebar { margin: 12px -4px 0; }
  .small, small, .pill, .sect > summary, code, .legend, .msyms small, .msyms .sig, .note { font-size: 12px !important; }
}
