/* ============================================================================
   Alien Algo — Premium Polish Layer
   Additive, cosmetic-only. Loads AFTER alienalgo-platform-v540.css so it wins on
   the cascade. Retunes the existing design tokens (the whole app inherits the
   upgrade) and refines the most-repeated components. No layout/position changes,
   no pointer-events changes — safe to remove by deleting the <link> to revert.
   ============================================================================ */

/* ---- 1. Design tokens: deeper, calmer neutrals + a refined accent -------- */
html[data-theme="dark"], :root {
  --bg:        #070a0f;
  --bg-2:      #0b0f16;
  --surface:   #0e141f;
  --surface-2: #141c2b;
  --line:      #1d2735;
  --line-2:    #2c3a4e;
  --text:      #f6f8fb;
  --text-2:    #c4cdda;
  --text-3:    #8b97a8;
  --text-4:    #5c6577;
  --alien:     #00e6a0;
  --alien-2:   #35ffcd;
  --shadow:    0 1px 2px rgba(0,0,0,.45), 0 18px 48px rgba(0,0,0,.55);
  --aa-radius:    14px;
  --aa-radius-sm: 10px;
  --aa-ring:      0 0 0 3px rgba(0,230,160,.30);
  --aa-elev-1:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.42);
  --aa-elev-2:    0 2px 6px rgba(0,0,0,.45), 0 22px 60px rgba(0,0,0,.55);
  --aa-hairline:  inset 0 1px 0 rgba(255,255,255,.05);
  --aa-cta:       linear-gradient(180deg, #16f3ac 0%, #00d38f 100%);
  --aa-cta-text:  #04140d;
  --aa-glass:     rgba(14,20,31,.72);
}
html[data-theme="light"] {
  --bg:        #eceff4;
  --bg-2:      #eef1f6;
  --surface:   #ffffff;
  --surface-2: #f5f8fb;
  --line:      #dde3ec;
  --line-2:    #c4ccd9;
  --text:      #0f172a;
  --text-2:    #3a465a;
  --text-3:    #6a7688;
  --text-4:    #8994a5;
  --alien:     #05b784;
  --alien-2:   #00d39a;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 18px 48px rgba(15,23,42,.13);
  --aa-ring:   0 0 0 3px rgba(5,183,132,.22);
  --aa-elev-1: 0 1px 2px rgba(15,23,42,.05), 0 8px 22px rgba(15,23,42,.09);
  --aa-elev-2: 0 2px 6px rgba(15,23,42,.07), 0 22px 56px rgba(15,23,42,.14);
  --aa-hairline: inset 0 1px 0 rgba(255,255,255,.7);
  --aa-cta:      linear-gradient(180deg, #0acc90 0%, #05a978 100%);
  --aa-cta-text: #ffffff;
  --aa-glass:    rgba(255,255,255,.78);
}

/* ---- 2. Global rendering polish ----------------------------------------- */
body, .app, .aa-app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(0,230,160,.28); }

/* Refined thin scrollbars (WebKit + Firefox) */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Calm micro-interaction timing on interactive elements */
button, .set-row, .trade-tab, .aa-ai-chip, .cal-switch-btn, .wl-sorttabs button,
.aa-tool-menu-item, .aa-indicator-type, input, textarea, select {
  transition: background-color .18s ease, border-color .18s ease,
              box-shadow .18s ease, color .18s ease, transform .12s ease;
}

/* On-brand focus rings */
button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: none !important;
  box-shadow: var(--aa-ring) !important;
  border-radius: var(--aa-radius-sm);
}

/* ---- 3. Primary call-to-action buttons ---------------------------------- */
.aa-auth-cta, .acct-cta, .set-load-token-btn, .disc-ai-btn, .aa-acct-cta {
  background: var(--aa-cta) !important;
  color: var(--aa-cta-text) !important;
  border: none !important;
  border-radius: var(--aa-radius) !important;
  font-weight: 700 !important;
  letter-spacing: .01em;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 22px rgba(0,211,143,.28) !important;
}
.aa-auth-cta:hover, .acct-cta:hover, .set-load-token-btn:hover, .disc-ai-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 12px 30px rgba(0,211,143,.38) !important;
}
.aa-auth-cta:active, .acct-cta:active, .set-load-token-btn:active, .disc-ai-btn:active {
  transform: translateY(0);
  filter: brightness(.98);
}
.aa-ohlc-action-btn-v439, .settings-action, .set-sub-act, .wl-icon-btn {
  border-radius: var(--aa-radius-sm) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--aa-hairline);
}
.aa-ohlc-action-btn-v439:hover, .settings-action:hover, .set-sub-act:hover {
  border-color: var(--alien) !important;
  color: var(--text) !important;
}
.top-tool-btn { border-radius: var(--aa-radius-sm) !important; }
.top-tool-btn:hover { border-color: var(--line-2) !important; }
.top-tool-btn.aa-tool-main.active, .top-tool-btn.active { box-shadow: var(--aa-hairline); }

/* ---- 4. Inputs, fields & textareas -------------------------------------- */
.aa-field input, .aa-auth-card input, #aaAiInput, .wl-searchbar input,
.wl-picker-search input, input[type="text"], input[type="email"],
input[type="password"], input[type="tel"], input[type="number"], textarea {
  border-radius: var(--aa-radius-sm) !important;
  border: 1px solid var(--line) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
.aa-field input:focus, .aa-auth-card input:focus, #aaAiInput:focus, input:focus, textarea:focus {
  border-color: var(--alien) !important;
  box-shadow: var(--aa-ring) !important;
}
.aa-field span { letter-spacing: .01em; color: var(--text-3); }
.aa-ai-input-shell {
  border-radius: 16px !important;
  border: 1px solid var(--line) !important;
  background: var(--surface-2) !important;
  box-shadow: var(--aa-elev-1);
}
.aa-ai-input-shell:focus-within {
  border-color: var(--alien) !important;
  box-shadow: var(--aa-ring), var(--aa-elev-1) !important;
}
.aa-send-icon { background: var(--aa-cta) !important; color: var(--aa-cta-text) !important; border-radius: 10px !important; }

/* ---- 5. Cards & surfaces ------------------------------------------------- */
.set-card, .aa-bottom-metrics article, .disc-pnl-card, .disc-ai-card,
.acct-detail-card, .acct-fields-card, .acct-mt5-card, .disc-float-card,
.aa-usage-wrap, .set-upsell {
  border-radius: var(--aa-radius) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--aa-elev-1), var(--aa-hairline) !important;
}
.disc-ai-card {
  background: radial-gradient(120% 100% at 0% 0%, rgba(0,230,160,.08), transparent 60%), var(--surface) !important;
  border-color: color-mix(in srgb, var(--alien) 30%, var(--line)) !important;
}
.aa-bottom-metrics article:hover, .disc-pnl-card:hover { border-color: var(--line-2) !important; }
.set-sec-label, .acct-sec-label, .aa-ai-drawer-label {
  text-transform: uppercase; letter-spacing: .09em; font-size: 11px; color: var(--text-3) !important;
}
.set-ava, .acct-hero-ava, .disc-ai-orb, .aa-ai-orb {
  background: var(--aa-cta) !important; color: var(--aa-cta-text) !important;
  box-shadow: 0 6px 18px rgba(0,211,143,.32);
}
.acct-plan-badge, .set-pro { border-radius: 999px !important; letter-spacing: .04em; font-weight: 700 !important; }

/* ---- 6. Auth dialog ----------------------------------------------------- */
.aa-auth-card, .aa-auth-card-v835 {
  border-radius: 22px !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--aa-elev-2) !important;
}
.aa-auth-dialog::backdrop { background: rgba(4,7,11,.55); backdrop-filter: blur(6px) saturate(1.1); }
.aa-auth-h { letter-spacing: -.01em; }
.aa-auth-cta { width: 100%; }

/* ---- 7. Floating surfaces: glass ---------------------------------------- */
.aa-mobile-tabs {
  background: var(--aa-glass) !important;
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line) !important;
}
.aa-mobile-tabs button.active { color: var(--alien) !important; }
.aa-mobile-tabs button.active .aa-tab-ico { filter: drop-shadow(0 0 10px rgba(0,230,160,.5)); }
.aa-tool-menu, .aa-indicators-menu, .aa-bar-type-menu, .aa-mini-popover,
.aa-ai-drawer, .disc-day-sheet, .cal-detail-body {
  border-radius: var(--aa-radius) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--aa-elev-2) !important;
}
.aa-tool-menu, .aa-indicators-menu, .aa-bar-type-menu, .aa-mini-popover {
  background: var(--aa-glass) !important;
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
}
.aa-tool-menu-item:hover, .aa-indicator-type:hover {
  background: color-mix(in srgb, var(--alien) 12%, transparent) !important;
}

/* ---- 8. Tabs, chips & pills --------------------------------------------- */
.trade-tab.active, .cal-switch-btn.active, .wl-sorttabs button.active { color: var(--alien) !important; }
.aa-ai-chip { border-radius: 999px !important; border: 1px solid var(--line) !important; background: var(--surface-2) !important; }
.aa-ai-chip:hover { border-color: var(--alien) !important; color: var(--text) !important; transform: translateY(-1px); }
.aa-ai-messages .aa-ai-msg, .aa-ai-messages .msg, .aa-ai-bubble { border-radius: 16px !important; }

/* ---- 9. Bias / status strips -------------------------------------------- */
.bias-strip, .news-bias-strip, .tv-newsbias { border-radius: 999px !important; box-shadow: var(--aa-hairline); }
.conn { border-radius: 999px !important; }
.conn .dot { box-shadow: 0 0 8px currentColor; }

/* ---- 10. Toggles + dividers + brand glow -------------------------------- */
.set-toggle { accent-color: var(--alien); }
.set-div { background: var(--line) !important; opacity: .7; }
.aa-ai-orb, .tv-app-dot { box-shadow: 0 0 20px rgba(0,230,160,.45); }

/* Reduced-motion users: drop the lift/scale animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; }
  .aa-auth-cta:hover, .aa-ai-chip:hover, .acct-cta:hover { transform: none; }
}

/* ---- Trade-signal card: Show-on-chart button + live status label -------- */
.ti-setup-actions { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:10px; flex-wrap:wrap; }
.ti-setup-status { font-size:11px; font-weight:600; color:var(--text-3); letter-spacing:.01em; }
.ti-setup.active .ti-setup-status { color:var(--alien); }
.ti-setup.won .ti-setup-status { color:#12b981; }
.ti-setup.lost .ti-setup-status { color:#ef4444; }
.ti-setup-chartbtn { font-size:12px; font-weight:600; padding:7px 12px; border-radius:999px; border:1px solid var(--line); background:var(--surface-2); color:var(--text); cursor:pointer; }
.ti-setup-chartbtn:hover { border-color:var(--alien); color:var(--text); }
.ta-showchart { width:100%; margin-top:10px; border-radius:12px; }

/* ============================================================================
   v1011 — Chart settings sub-page (premium, TradingView-style)
   ============================================================================ */
.chart-set-body { padding:14px 14px 40px; display:flex; flex-direction:column; gap:16px; }
.chart-set-hero {
  position:relative; display:flex; flex-direction:column; align-items:flex-start; gap:6px;
  padding:18px 18px 20px; border-radius:var(--aa-radius);
  background:linear-gradient(150deg, var(--surface-2) 0%, var(--surface) 60%);
  border:1px solid var(--line); box-shadow:var(--aa-elev-1); overflow:hidden;
}
.chart-set-hero::after {
  content:""; position:absolute; top:-40%; right:-10%; width:180px; height:180px; border-radius:50%;
  background:radial-gradient(circle, rgba(0,230,160,.18), transparent 70%); pointer-events:none;
}
.chart-set-hero-orb {
  width:44px; height:44px; border-radius:13px; display:inline-flex; align-items:center; justify-content:center;
  font-size:22px; background:var(--surface); border:1px solid var(--line-2); box-shadow:var(--aa-hairline); margin-bottom:2px;
}
.chart-set-hero b { font-size:17px; font-weight:800; letter-spacing:-.01em; color:var(--text); }
.chart-set-hero small { font-size:12.5px; line-height:1.5; color:var(--text-3); max-width:38ch; }

.chart-set-card {
  border-radius:var(--aa-radius); border:1px solid var(--line);
  background:var(--surface); box-shadow:var(--aa-elev-1); overflow:hidden;
}
.chart-set-card #aaChartSettingsGroup { display:flex; flex-direction:column; }
.chart-set-card .settings-row {
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  min-height:52px; padding:11px 16px; margin:0; cursor:pointer;
  border-bottom:1px solid var(--line); font-size:14px; color:var(--text); font-weight:500;
}
.chart-set-card .settings-row:last-child { border-bottom:0; }
.chart-set-card .settings-row:hover { background:var(--surface-2); }
.chart-set-card .settings-row > span { flex:1 1 auto; }

/* Toggles → premium iOS-style switch */
.chart-set-card .settings-row input[type="checkbox"] {
  -webkit-appearance:none; appearance:none; flex:0 0 auto; position:relative;
  width:44px; height:26px; border-radius:999px; background:var(--line-2); cursor:pointer;
  transition:background .2s ease; margin:0; border:0;
}
.chart-set-card .settings-row input[type="checkbox"]::after {
  content:""; position:absolute; top:3px; left:3px; width:20px; height:20px; border-radius:50%;
  background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.35); transition:transform .2s ease;
}
.chart-set-card .settings-row input[type="checkbox"]:checked { background:var(--aa-cta); }
.chart-set-card .settings-row input[type="checkbox"]:checked::after { transform:translateX(18px); }

/* Colour swatches */
.chart-set-card .color-row input[type="color"] {
  -webkit-appearance:none; appearance:none; flex:0 0 auto; width:40px; height:28px;
  border:1px solid var(--line-2); border-radius:8px; background:transparent; cursor:pointer; padding:0;
}
.chart-set-card .color-row input[type="color"]::-webkit-color-swatch-wrapper { padding:2px; }
.chart-set-card .color-row input[type="color"]::-webkit-color-swatch { border:0; border-radius:6px; }

/* Range → slim accent track */
.chart-set-card .settings-row input[type="range"] {
  -webkit-appearance:none; appearance:none; flex:0 0 140px; height:6px; border-radius:999px;
  background:var(--line-2); cursor:pointer; margin:0;
}
.chart-set-card .settings-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance:none; appearance:none; width:18px; height:18px; border-radius:50%;
  background:#fff; border:1px solid var(--line-2); box-shadow:0 1px 3px rgba(0,0,0,.35); cursor:pointer;
}
.chart-set-card .settings-row input[type="range"]::-moz-range-thumb {
  width:18px; height:18px; border-radius:50%; background:#fff; border:1px solid var(--line-2); cursor:pointer;
}
/* The Chart settings entry row shows a subtitle like the other premium rows */
#aaChartSetOpen .set-row-title { display:flex; flex-direction:column; gap:2px; text-align:left; }
#aaChartSetOpen .set-row-title small { font-size:11.5px; color:var(--text-3); font-weight:500; }

/* ============================================================================
   v1014 — Dedicated drawing-tools sheet (#aaDrawToolsSheet), a body-level fixed panel with its
   own backdrop and top z-index so it can never be trapped/clipped by a stacking context. Works
   identically on desktop (docked card top-left over the chart) and compact (bottom sheet).
   ============================================================================ */
#aaDrawToolsScrim{ position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:2147483600; }
#aaDrawToolsScrim[hidden]{ display:none; }
#aaDrawToolsSheet{
  position:fixed; top:92px; left:12px; width:264px; max-height:min(72vh, 560px); overflow:auto;
  z-index:2147483610; background:var(--surface); color:var(--text);
  border:1px solid var(--line-2); border-radius:14px; box-shadow:0 26px 74px rgba(0,0,0,.5);
  padding:8px; -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
  animation:aaDtsPop .16s ease;
}
#aaDrawToolsSheet[hidden]{ display:none; }
.aa-dts-head{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:6px 8px 8px; position:sticky; top:0; background:var(--surface); z-index:1;
  border-bottom:1px solid var(--line);
}
.aa-dts-head b{ font-size:13px; font-weight:900; color:var(--text); letter-spacing:.02em; }
.aa-dts-x{ width:28px; height:28px; flex:0 0 auto; border:1px solid var(--line-2); border-radius:8px; background:var(--surface-2); color:var(--text); font-size:16px; font-weight:800; line-height:1; cursor:pointer; }
.aa-dts-x:hover{ border-color:var(--alien); }
.aa-dts-body{ display:grid; gap:2px; padding-top:4px; }
.aa-dts-section{ font-size:9.5px; font-weight:900; text-transform:uppercase; letter-spacing:.12em; color:var(--text-4); padding:9px 8px 3px; }
.aa-dts-item{
  display:flex; align-items:center; height:40px; width:100%; padding:0 12px; gap:8px;
  border:0; border-radius:9px; background:transparent; color:var(--text-2);
  font-family:inherit; font-size:12.5px; font-weight:700; text-align:left; cursor:pointer;
}
.aa-dts-item:hover{ background:var(--surface-2); color:var(--text); }
.aa-dts-item.active{ background:rgba(0,230,160,.14); color:var(--text); }
.aa-dts-item.danger{ color:#ff8ba3; }
.aa-dts-item.danger:hover{ background:rgba(244,63,94,.14); }
/* Tool row = label button + ☆ favourite toggle */
.aa-dts-row{ display:flex; align-items:center; gap:4px; }
.aa-dts-row .aa-dts-item{ flex:1 1 auto; width:auto; }
.aa-dts-fav{
  flex:0 0 auto; width:32px; height:32px; border:0; border-radius:8px; background:transparent;
  color:var(--text-4); font-size:15px; line-height:1; cursor:pointer; transition:transform .12s ease, color .15s ease;
}
.aa-dts-fav:hover{ color:#f5b301; background:var(--surface-2); }
.aa-dts-fav.on{ color:#f5b301; }
.aa-dts-fav:active{ transform:scale(.9); }
@keyframes aaDtsPop{ from{ opacity:0; transform:translateY(-6px);} to{ opacity:1; transform:translateY(0);} }
@media (max-width: 820px){
  #aaDrawToolsSheet{
    top:auto; left:0; right:0; bottom:0; width:100%; max-height:76vh;
    border-radius:20px 20px 0 0; border-left:0; border-right:0; border-bottom:0;
    padding:8px 10px calc(16px + env(safe-area-inset-bottom, 0px));
    animation:aaDtsUp .24s cubic-bezier(.25,.8,.3,1);
  }
  .aa-dts-item{ height:46px; font-size:14px; }
  @keyframes aaDtsUp{ from{ transform:translateY(100%);} to{ transform:translateY(0);} }

  /* Lane hosts pair, timeframe, tool buttons AND undo/redo — let it scroll if it overflows */
  .tv-ticker-line{ overflow-x:auto !important; overflow-y:hidden !important; scrollbar-width:none; -webkit-overflow-scrolling:touch; }
  .tv-ticker-line::-webkit-scrollbar{ display:none; }
  .tv-ticker-line .tv-undo-redo.aa-lane-undo{
    display:inline-flex !important; visibility:visible !important; opacity:1 !important;
    flex:0 0 auto; gap:4px; margin:0 2px !important;
  }
  .tv-ticker-line .tv-undo-redo.aa-lane-undo button{
    width:30px !important; height:27px !important; border:1px solid var(--line); border-radius:6px;
    background:linear-gradient(180deg,var(--surface-2),var(--surface)); color:var(--text-2);
  }
  .tv-ticker-line .tv-undo-redo.aa-lane-undo button:disabled{ opacity:.35; }
}

/* ============================================================================
   v1015 — Indicators, Bar type & Object tree open as premium body-level sheets (shared backdrop),
   exactly like the drawing-tools sheet. Desktop = docked card top-left over the chart; compact =
   bottom sheet. High specificity + !important to override the menus' original docked/absolute CSS.
   ============================================================================ */
#aaSheetScrim{ position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:2147483600; }
#aaSheetScrim[hidden]{ display:none; }

#aaIndicatorsMenu.aa-sheet-panel,
#aaBarTypeMenu.aa-sheet-panel,
#aaMiniPopover.aa-objtree-sheet{
  position:fixed !important; top:92px !important; left:12px !important; right:auto !important; bottom:auto !important;
  width:288px !important; max-width:calc(100vw - 24px) !important; max-height:min(74vh, 600px) !important;
  overflow:auto !important; z-index:2147483610 !important;
  background:var(--surface) !important; color:var(--text) !important;
  border:1px solid var(--line-2) !important; border-radius:16px !important;
  box-shadow:0 26px 74px rgba(0,0,0,.5) !important; padding:8px !important;
  -webkit-overflow-scrolling:touch; overscroll-behavior:contain; isolation:isolate;
  animation:aaDtsPop .16s ease;
}
/* Premium header for each sheet (reuses existing head markup) */
.aa-sheet-panel .aa-indicators-head,
#aaMiniPopover.aa-objtree-sheet .aa-pop-head{
  position:sticky; top:0; z-index:1; background:var(--surface);
  border-bottom:1px solid var(--line); margin:-8px -8px 6px; padding:12px 14px !important; border-radius:16px 16px 0 0;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  color:var(--text) !important; font-size:13px !important; font-weight:900 !important; letter-spacing:.02em;
}
#aaMiniPopover.aa-objtree-sheet .aa-pop-head{ background:var(--surface) !important; }
#aaMiniPopover.aa-objtree-sheet .aa-pop-head b{ color:var(--text) !important; text-transform:none !important; letter-spacing:.02em !important; font-size:13px !important; }
.aa-sheet-panel .aa-indicators-head button,
#aaMiniPopover.aa-objtree-sheet .aa-pop-head button{
  width:28px; height:28px; flex:0 0 auto; border:1px solid var(--line-2); border-radius:8px;
  background:var(--surface-2); color:var(--text); font-weight:800; cursor:pointer;
}
.aa-sheet-panel .aa-indicators-head button:hover,
#aaMiniPopover.aa-objtree-sheet .aa-pop-head button:hover{ border-color:var(--alien); }

/* Premium item cards inside Indicators / Bar type */
.aa-sheet-panel .aa-indicator-type{
  width:100%; text-align:left; border:1px solid var(--line) !important; border-radius:11px !important;
  background:var(--surface-2) !important; padding:11px 13px !important; margin:0 0 6px !important;
  display:flex; flex-direction:column; gap:2px; cursor:pointer; transition:border-color .15s ease, transform .1s ease;
}
.aa-sheet-panel .aa-indicator-type:hover{ border-color:var(--alien) !important; }
.aa-sheet-panel .aa-indicator-type:active{ transform:scale(.99); }
.aa-sheet-panel .aa-indicator-type b{ font-size:13px; font-weight:800; color:var(--text); }
.aa-sheet-panel .aa-indicator-type small{ font-size:11px; color:var(--text-3); line-height:1.4; }
.aa-sheet-panel .aa-indicators-body{ display:grid; gap:6px; }
.aa-sheet-panel .aa-indicators-head + *{ margin-top:2px; }

/* Object tree rows — premium list */
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-summary{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  font-size:11px; color:var(--text-3); padding:4px 6px 10px;
}
#aaMiniPopover.aa-objtree-sheet .aa-indicator-list-head{
  font-size:9.5px; font-weight:900; text-transform:uppercase; letter-spacing:.12em; color:var(--text-4); padding:8px 6px 4px;
  display:flex; align-items:baseline; gap:8px;
}
#aaMiniPopover.aa-objtree-sheet .aa-indicator-list-head small{ font-weight:600; letter-spacing:0; text-transform:none; color:var(--text-4); }
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row{
  display:flex; align-items:center; gap:6px; border:1px solid var(--line); border-radius:10px;
  background:var(--surface-2); padding:8px 10px; margin-bottom:6px;
}
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row b{ flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:1px; font-size:12.5px; font-weight:700; color:var(--text); }
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row b i{ width:10px; height:10px; border-radius:3px; display:inline-block; margin-right:6px; vertical-align:middle; }
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row small{ font-size:10px; font-weight:600; color:var(--text-4); }
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row button{
  flex:0 0 auto; height:28px; padding:0 10px; border:1px solid var(--line-2); border-radius:8px;
  background:var(--surface); color:var(--text-2); font-size:11px; font-weight:700; cursor:pointer;
}
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row button:hover{ border-color:var(--alien); color:var(--text); }
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row button.danger{ color:#ff8ba3; }
#aaMiniPopover.aa-objtree-sheet .aa-hidden-drawings-row.is-hidden{ opacity:.6; }

@media (max-width: 820px){
  #aaIndicatorsMenu.aa-sheet-panel,
  #aaBarTypeMenu.aa-sheet-panel,
  #aaMiniPopover.aa-objtree-sheet{
    top:auto !important; left:0 !important; right:0 !important; bottom:0 !important;
    width:100% !important; max-width:100% !important; max-height:80vh !important;
    border-radius:20px 20px 0 0 !important; border-left:0 !important; border-right:0 !important; border-bottom:0 !important;
    padding:8px 12px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    animation:aaDtsUp .24s cubic-bezier(.25,.8,.3,1);
  }
}

/* ============================================================================
   v1016 — Full-screen toggle, fit-to-current-bar floater
   ============================================================================ */
.aa-mobile-tabs{ transition:transform .3s cubic-bezier(.3,.8,.3,1); }
.aa-lane-fs.active{ color:var(--alien) !important; }
/* The grid collapse is applied INLINE by JS (using real computed row heights) so it beats every
   media-query !important; this just keeps the tabs non-interactive while slid away. */
.aa-app.aa-fullscreen .aa-mobile-tabs{ pointer-events:none; }

/* Fit-to-current-bar floater — bottom-right of the chart, only when the live bar is out of view */
#aaFitNowBtn.aa-fit-now{
  position:absolute; right:56px; bottom:30px; z-index:45;
  width:34px; height:34px; display:none; align-items:center; justify-content:center;
  border:1px solid var(--line-2); border-radius:50%; background:var(--surface); color:var(--text);
  box-shadow:0 6px 20px rgba(0,0,0,.35); cursor:pointer; opacity:0; transform:translateY(6px);
  transition:opacity .18s ease, transform .18s ease, border-color .15s ease, color .15s ease;
}
#aaFitNowBtn.aa-fit-now.show{ display:flex; opacity:1; transform:translateY(0); }
#aaFitNowBtn.aa-fit-now:hover{ border-color:var(--alien); color:var(--alien); }
#aaFitNowBtn.aa-fit-now:active{ transform:scale(.94); }

/* v1017/1018 — full-screen is compact-only; hide its button on desktop (ID selector beats any class) */
@media (min-width: 821px){ #aaFullscreenBtn, #aaFullscreenBtn.aa-lane-fs, #aaFullscreenBtn.aa-lane-icobtn{ display:none !important; } }

/* ============================================================================
   v1018 — KEYBOARD INPUT FIX. The app-wide user-select:none (Capacitor native +
   chart wrap) was stopping iOS from focusing text fields, so the device keyboard
   never opened for indicator / drawing / any text inputs. Re-enable selection,
   callout and touch on every editable control everywhere.
   ============================================================================ */
input, textarea, select, [contenteditable], [contenteditable="true"],
.aa-mini-popover input, .aa-mini-popover textarea, .aa-mini-popover select,
#aaAiInput, .aa-ai-input-shell textarea, .aa-ai-input-shell input {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
  touch-action: auto !important;
  pointer-events: auto !important;
}
/* The settings popover itself must accept touches (it sits over the touch-action:none chart) */
.aa-mini-popover, .aa-mini-popover * { touch-action: auto; }
.aa-mini-popover.aa-drawing-settings, .aa-mini-popover.aa-indicator-settings { -webkit-user-select: text; user-select: text; }

/* ============================================================================
   v1019 — Full-screen fill is driven by JS (main area pinned position:fixed to the
   viewport bottom); CSS just slides the tabs out and blocks their taps.
   ============================================================================ */
@media (max-width: 820px){
  /* v1024 — fullscreen collapses ONLY the bottom tab track. The chart row (1fr) grows to fill it and
     the pair/timeframe lane (#aaChartBottomBar, grid-row 2) stays a real row directly below the chart,
     so nothing overlaps the chart's time axis. Body-scoped + .aa-fullscreen out-specifies the base
     grid rule (body.aa-chart-bottom-header #aaApp[data-panel="chart"]). */
  body.aa-chart-bottom-header.aa-fullscreen #aaApp[data-panel="chart"],
  body.aa-chart-bottom-header #aaApp.aa-fullscreen[data-panel="chart"]{
    grid-template-rows:minmax(0,1fr) auto 0px !important;
  }
  #aaApp.aa-fullscreen .aa-mobile-tabs,
  body.aa-fullscreen #aaApp .aa-mobile-tabs{
    display:none !important; height:0 !important; min-height:0 !important; max-height:0 !important;
    padding:0 !important; border:0 !important; pointer-events:none !important;
  }
}

/* ============================================================================
   v1027 — AI chat composer: pin it, don't float it. The two remaining bugs had ONE cause: the AI page
   itself scrolls (.aa-panel-page has overflow:auto), so the composer — the last child — scrolled with
   the bubbles ("drifts up and down") and never anchored to the bottom (so the freed tab strip stayed
   blank). position:fixed was wrong (it jumps on iOS and doesn't fill the panel). Instead: make the AI
   page a NON-scrolling flex column where ONLY the message list scrolls and the composer is a fixed
   bottom row — ALWAYS, keyboard or not. Then to handle the keyboard we just move the PANEL's bottom
   edge (it's position:fixed on compact) up to the keyboard top / down over the freed tab strip. The
   composer rides the panel bottom, so it fills the tab space and sits above the keyboard with no drift.
   ============================================================================ */
@media (max-width: 820px){
  /* Only the message list scrolls; the composer is a pinned bottom row of the AI page. */
  #aaApp .aa-panel-page[data-panel-page="ai"]{ overflow:hidden !important; }
  #aaApp .aa-panel-page[data-panel-page="ai"] .aa-ai-messages{
    flex:1 1 auto !important; min-height:0 !important; overflow:auto !important; -webkit-overflow-scrolling:touch !important;
  }
  #aaApp .aa-panel-page[data-panel-page="ai"] .aa-ai-form,
  #aaApp .aa-panel-page[data-panel-page="ai"] .aa-ai-form-v512{
    flex:0 0 auto !important; position:static !important; margin:0 !important; background:var(--bg) !important;
  }
  /* Keyboard handling is already done by the existing rule that sizes the panel to --aa-vvh (top:0 +
     height:above-keyboard), so the pinned composer lands right on the keyboard top and the freed tab
     strip is covered. Nothing extra needed here now that the composer no longer scrolls. */
}

/* ============================================================================
   v1018 — Drawing / indicator SETTINGS popover: raise above every backdrop so it
   always shows, and give it a premium sheet look with comfortable, typeable rows.
   ============================================================================ */
.aa-mini-popover.aa-drawing-settings, .aa-mini-popover.aa-indicator-settings{
  z-index:2147483620 !important;
  border:1px solid var(--line-2) !important; border-radius:16px !important;
  background:var(--surface) !important; color:var(--text) !important;
  box-shadow:0 26px 74px rgba(0,0,0,.5) !important; overflow:hidden !important;
  width:min(320px, calc(100vw - 20px)) !important;
}
.aa-mini-popover.aa-drawing-settings .aa-pop-head, .aa-mini-popover.aa-indicator-settings .aa-pop-head{
  background:var(--surface-2) !important; color:var(--text) !important; border-bottom:1px solid var(--line) !important; height:auto !important; padding:12px 14px !important;
}
.aa-mini-popover.aa-drawing-settings .aa-pop-head b, .aa-mini-popover.aa-indicator-settings .aa-pop-head b{ color:var(--text) !important; font-size:13px !important; text-transform:none !important; letter-spacing:.01em !important; }
.aa-mini-popover .aa-pop-body label, .aa-mini-popover .aa-indicator-settings-body label{
  display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; padding:6px 2px;
  font-size:12.5px; color:var(--text-2);
}
.aa-mini-popover .aa-pop-body input, .aa-mini-popover .aa-pop-body select,
.aa-mini-popover .aa-indicator-settings-body input, .aa-mini-popover .aa-indicator-settings-body select{
  height:38px; min-width:96px; border:1px solid var(--line) !important; border-radius:9px !important;
  background:var(--surface-2) !important; color:var(--text) !important; padding:0 10px; font:inherit; font-size:13px;
}
.aa-mini-popover input[type="color"]{ width:44px !important; min-width:44px !important; padding:2px !important; }
.aa-indicator-settings-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:6px; }
.aa-indicator-settings-actions button{
  flex:1 1 auto; min-height:40px; border:1px solid var(--line-2); border-radius:10px;
  background:var(--surface-2); color:var(--text); font-weight:700; cursor:pointer;
}
.aa-indicator-settings-actions button[data-indicator-save]{ background:var(--aa-cta); color:var(--aa-cta-text); border:0; }
.aa-indicator-settings-actions button.danger{ color:#ff8ba3; }

/* ============================================================================
   v1019 — iOS auto-zoom on input focus (the "whole platform zooms in" bug) fires
   whenever a focused field's font-size is < 16px. Force >=16px on every text field
   on compact so tapping an input opens the keyboard WITHOUT zooming the page.
   ============================================================================ */
@media (max-width: 820px){
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  textarea, select,
  #aaAiInput, .aa-mini-popover input, .aa-mini-popover textarea, .aa-mini-popover select,
  .aa-indicator-settings-body input, .aa-indicator-settings-body select {
    font-size: 16px !important;
  }
  /* Composer background so it reads solid at the bottom of the pinned AI panel grid */
  body.aa-ai-touch-keyboard #aaApp .aa-ai-form,
  body.aa-ai-touch-keyboard #aaApp .aa-ai-form-v512{ background: var(--bg) !important; }
}
