/* r316: chart-first touch, full screen to the screen edges (notch), layout save menu. Theme variables only. */

/* ---------- touch: the chart owns every gesture over it ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#chart, #chart canvas, .slot-card iframe { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stage { overscroll-behavior: none; }
button, .tb, .tf, .pi, .lay-b, .wsm-i { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------- full screen (real or chart mode) ---------- */
html.sc-full { --nav-h: 0px; }
html.sc-full body:not(.embed) .mnav { display: none !important; }
html.sc-full body:not(.embed) .app { height: var(--mobile-visible-height, 100dvh) !important; max-height: none !important; }
@media (max-width: 1024px) {
  html.sc-full body:not(.embed) .app { height: 100dvh !important; padding-left: 0 !important; padding-right: 0 !important; }
  html.sc-full body:not(.embed) .stage { padding-left: 0 !important; padding-right: 0 !important; padding-bottom: env(safe-area-inset-bottom) !important; }
  /* landscape: let the chart run under the notch side; keep the toolbar row clear of it */
  @media (orientation: landscape) {
    html.sc-full body:not(.embed) .top { padding-left: max(8px, env(safe-area-inset-left)) !important; padding-right: max(8px, env(safe-area-inset-right)) !important; }
  }
}
html.sc-full { background: var(--card); }
html.sc-full body { background: var(--card); }
.sc-full-exit { position: fixed; z-index: 60; right: calc(10px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--hair); background: var(--card); color: var(--t1); box-shadow: var(--shadow-2, 0 4px 14px rgba(0,0,0,.16)); display: grid; place-items: center; padding: 0; opacity: .9; }
.sc-full-exit[hidden] { display: none; }
@media (min-width: 1025px) { .sc-full-exit { display: none !important; } }
#fullBtn.on { color: var(--t1); background: var(--fill-2); }

/* ---------- Save button with layout name ---------- */
#saveWorkspace.ws-btn { width: auto; min-width: 34px; max-width: 190px; padding: 0 12px 0 8px; gap: 6px; display: inline-flex; align-items: center; justify-content: flex-start; }
#saveWorkspace.ws-btn .ws-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--t1); }
#saveWorkspace.ws-btn .save-dot { position: static; flex: none; box-shadow: none; margin-left: 1px; }
#saveWorkspace.ws-busy .save-dot { background: #f0a500; }
@media (max-width: 767px) {
  #saveWorkspace.ws-btn { max-width: 46px; padding: 0; justify-content: center; position: relative; }
  #saveWorkspace.ws-btn .ws-name { display: none; }
  #saveWorkspace.ws-btn .save-dot { position: absolute; right: 7px; top: 8px; box-shadow: 0 0 0 2px var(--card); }
}

/* ---------- layout save menu ---------- */
.wsm-pop { position: fixed; z-index: 1200; overflow-y: auto; overscroll-behavior: contain; padding: 6px; border: 1px solid var(--hair); border-radius: 12px; background: var(--card); color: var(--t1); box-shadow: var(--shadow-3, 0 12px 36px rgba(0,0,0,.2)); font-size: 13px; }
.wsm-top { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--hair); margin-bottom: 4px; }
.wsm-top b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsm-top small, .wsm-i small { color: var(--t3); font-size: 11px; }
.wsm-i { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--t1); font: inherit; text-align: left; cursor: pointer; }
.wsm-i:hover, .wsm-i:focus-visible { background: var(--fill-2); outline: none; }
.wsm-i > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsm-i kbd { font: 500 11px/1 var(--font); color: var(--t3); padding: 4px 6px; border: 1px solid var(--hair); border-radius: 5px; background: var(--fill); }
.wsm-l.on { background: var(--fill); }
.wsm-l.on > span { font-weight: 600; }
.wsm-sep { height: 1px; margin: 5px 4px; background: var(--hair); }
.wsm-sub { padding: 4px 10px 3px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--t3); }
.wsm-list { max-height: 210px; overflow-y: auto; }
.wsm-empty { margin: 4px 10px 8px; color: var(--t3); font-size: 12px; }
.wsm-tg { cursor: pointer; }
.wsm-tg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.wsm-tg i { position: relative; flex: none; width: 32px; height: 18px; border-radius: 999px; background: var(--fill-2); transition: background .15s; }
.wsm-tg i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.wsm-tg input:checked + i { background: var(--accent-strong, var(--t1)); }
.wsm-tg input:checked + i::after { transform: translateX(14px); }
.wsm-tg input:focus-visible + i { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

/* name dialog */
.wsm-dlg { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.38); }
.wsm-card { width: min(380px, 100%); padding: 16px; border: 1px solid var(--hair); border-radius: 14px; background: var(--card); color: var(--t1); box-shadow: var(--shadow-3, 0 16px 44px rgba(0,0,0,.25)); }
.wsm-h { display: flex; align-items: center; margin-bottom: 12px; }
.wsm-h b { flex: 1; font-size: 15px; font-weight: 600; }
.wsm-x { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--t2); font-size: 20px; line-height: 1; cursor: pointer; }
.wsm-x:hover { background: var(--fill-2); }
.wsm-in { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--hair); border-radius: 10px; background: var(--fill); color: var(--t1); font: inherit; font-size: 14px; }
.wsm-in:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.wsm-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@media (max-width: 767px) {
  .wsm-pop { left: 8px !important; right: 8px; width: auto !important; }
  .wsm-i { min-height: 44px; }
}
