/* AI Space Mobile v1, source of truth: CEXlens AI Space Mobile v1.dc.html.
   Desktop keeps the existing operations workspace. */
.aim-mobile { display: none; }

@media (max-width: 860px) {
  html { overflow-y: auto; scrollbar-gutter: auto; }
  body.ai-space {
    --bg-page: #f3f2ee;
    --bg-card: #fbfaf7;
    --bg-card2: #ecebe5;
    --bg-input: #fff;
    --bg-nav: #fbfaf7;
    --bg-hover: #efeafd;
    --tint: #efeafd;
    --tint-line: rgba(106, 61, 240, .45);
    --text-mid: #5a625d;
    --text-off: #9aa29d;
    --line: rgba(20, 33, 29, .08);
    --bull-fill: #4fb38f;
    --bear-fill: #d97a83;
    --bull-tint: #e2f1ea;
    --bear-tint: #f7e3e4;
    --warn: #9a6a00;
    --text-hi: #14211d;
    --text-md: #2a3430;
    --text-lo: #7a817c;
    --border: rgba(20, 33, 29, .14);
    --border2: rgba(20, 33, 29, .14);
    --accent: #6a3df0;
    --accent-2: #4d27bd;
    --bull: #1f7a57;
    --bear: #b8434b;
    --green: #1f7a57;
    --red: #b8434b;
    --orange: #9a6a00;
    --font: var(--font-ai);
    background: var(--bg-page);
    color: var(--text-hi);
    font-family: var(--font-ai);
    font-variant-numeric: tabular-nums;
  }
  body.ai-space button,
  body.ai-space input,
  body.ai-space select,
  body.ai-space textarea { font-family: var(--font-ai); }
  body.ai-space .mono,
  body.ai-space [class*="-caps"],
  body.ai-space .aim-mobile small,
  body.ai-space .aim-mobile header,
  body.ai-space .aim-mobile em,
  body.ai-space .aim-mobile strong { font-variant-numeric: tabular-nums; }

  body.ai-feed-page > main.main,
  body.ai-feed-page > #ai-tab-content > main.main,
  body.ai-setups-page > main.main,
  body.ai-setups-page > #ai-tab-content > main.main,
  body.ai-agents-page > main.main,
  body.ai-agents-page > #ai-tab-content > main.main,
  body.ai-profile-page > main.main,
  body.ai-profile-page > #ai-tab-content > main.main,
  body.ai-guide-page > main.main,
  body.ai-guide-page > #ai-tab-content > main.main { display: none !important; }

  .ark-mobile-page-head {
    height: var(--mobile-header-h);
    padding: calc(env(safe-area-inset-top, 0px) + 3px) 6px 0 4px;
    gap: 2px;
    background: var(--bg-card);
    border-bottom-color: var(--line);
  }
  .ark-mobile-head-spectrum { grid-template-columns: repeat(3, 1fr); }
  .ark-mobile-head-spectrum i:nth-child(1) { background: var(--accent-fill, var(--accent)); }
  .ark-mobile-head-spectrum i:nth-child(2) { background: #e8875b; }
  .ark-mobile-head-spectrum i:nth-child(3) { background: var(--bull-fill); }
  .ark-mobile-page-menu,
  .ark-mobile-head-search { width: 40px; height: 40px; color: var(--text-hi); }
  .ark-mobile-page-menu svg { width: 22px; height: 22px; }
  .ark-mobile-head-search svg { width: 21px; height: 21px; }
  .ark-mobile-page-brand img { width: 16px; height: 20px; }
  .ark-mobile-page-title { font-size: 16px; letter-spacing: 0; }
  .ark-mobile-head-side--end { gap: 2px; }
  .ark-mobile-session { padding-right: 4px; align-items: center; }
  .ark-mobile-session small { font: 400 8.5px var(--mono); letter-spacing: .1em; }
  .ark-mobile-session b { font: 600 11px var(--mono); color: var(--accent); }

  .aim-mobile {
    display: flex;
    width: min(100%, 430px);
    min-height: calc(100dvh - 99px - var(--bottom-nav-h, 58px) - var(--cp-bar-h, 0px));
    margin: 0 auto;
    padding: 10px 16px 16px;
    box-sizing: border-box;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-page);
  }
  .aim-mobile a { color: inherit; text-decoration: none; }
  .aim-mobile .mat-ic { flex: none; }
  .aim-mobile .field { min-width: 0; padding-right: 8px; padding-left: 8px; }
  .aim-mobile .field > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .aim-mobile .av { display: inline-flex; flex: none; align-items: center; justify-content: center; border-radius: 0 !important; color: #fff; font-weight: 700; }

  .aim-joined {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: 34px;
    border: 1px solid var(--border);
    background: var(--bg-card);
  }
  .aim-joined > a,
  .aim-joined > span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    border-left: 1px solid var(--line);
    font-size: 12.5px;
    font-weight: 600;
  }
  .aim-joined > :first-child { border-left: 0; }
  .aim-joined > .active { color: var(--accent-2); background: var(--tint); box-shadow: inset 0 0 0 1px var(--tint-line); }
  .aim-joined small { color: var(--text-lo); font: 500 10px var(--mono); }
  .aim-dropdowns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; position: relative; z-index: 5; }
  .aim-dropdowns.aim-dropdowns-three { grid-template-columns: minmax(0,1.35fr) minmax(0,.75fr) minmax(0,.9fr); }
  .aim-dropdowns-three .mini-dd-trigger { padding-right: 6px; padding-left: 6px; }
  .aim-dropdown { width: 100%; }
  .aim-dropdown.open { z-index: 2; }
  .aim-dropdown .mini-dd-trigger { display: grid; width: 100%; grid-template-columns: auto minmax(0, 1fr) 18px; gap: 6px; text-align: left; }
  .aim-dropdown-icon { display: flex; min-width: 0; align-items: center; overflow: visible; }
  .aim-dropdown-icon > * + * { margin-left: -5px; }
  .aim-dropdown-icon:empty { display: none; }
  .aim-dropdown-icon:empty + .mini-dd-val { grid-column: 1 / 3; }
  .aim-dropdown-option-icon { display: inline-flex; width: 18px; min-width: 18px; align-items: center; }
  .aim-dropdown-option-icon:has(> * + *) { width: 31px; min-width: 31px; }
  .aim-dropdown-option-icon > * + * { margin-left: -5px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--bg-card); }
  .aim-dropdown img { border-radius: 50%; }
  .aim-dropdown .mini-dd-panel { right: auto; left: 0; min-width: 100%; max-width: calc(100vw - 32px); max-height: min(320px, 50vh); overflow-y: auto; }
  .aim-dropdown.align-end .mini-dd-panel { right: 0; left: auto; }
  .aim-dropdown .menu-item { font-family: var(--font-ai); font-size: 12.5px; }

  .aim-feed-list { display: flex; flex-direction: column; gap: 10px; }
  .aim-feed-card { position: relative; }
  body.ai-space .aim-feed-card.card { padding: 0; }
  .aim-feed-open { position: absolute; inset: 0; z-index: 1; }
  .aim-author { display: grid; grid-template-columns: 22px auto 1fr auto; gap: 7px; align-items: center; padding: 10px 12px 5px; }
  .aim-author b { overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
  .aim-author small { color: var(--text-lo); font: 500 9.5px var(--mono); text-transform: uppercase; }
  .aim-verdict { padding: 2px 6px; background: var(--bg-card2); color: var(--text-mid); font: 700 9px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
  .aim-verdict.bull { background: var(--bull-tint); color: var(--bull); }
  .aim-verdict.bear { background: var(--bear-tint); color: var(--bear); }
  .aim-feed-card h2 { margin: 0; padding: 3px 12px 10px; color: var(--text-hi); font-size: 15px; line-height: 1.25; letter-spacing: -.01em; }
  .aim-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .aim-facts > span { min-width: 0; padding: 8px 12px; border-left: 1px solid var(--line); }
  .aim-facts > span:first-child { border-left: 0; }
  .aim-facts small,
  .aim-facts b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .aim-facts small { color: var(--text-lo); font: 500 9px var(--mono); letter-spacing: .1em; }
  /* The label names the number: it wraps to two lines instead of hiding the word (D-066). */
  .aim-facts small { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .aim-facts b { margin-top: 4px; font: 500 13px var(--mono); }
  /* A value is meaning: it wraps to a second line rather than losing its end. */
  .aim-facts b { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .aim-feed-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; gap: 8px; align-items: center; min-height: 36px; padding: 0 8px 0 12px; color: var(--text-lo); font-size: 10.5px; }
  .aim-feed-foot > span { display: flex; align-items: center; gap: 5px; }
  .aim-feed-foot b { color: var(--text-hi); font: 600 11px var(--mono); }
  .aim-more { align-self: center; min-height: 40px; color: var(--accent-2); font-size: 12.5px; font-weight: 700; }

  .aim-empty { display: flex; min-height: 112px; padding: 20px; align-items: center; justify-content: center; flex-direction: column; gap: 6px; color: var(--text-mid); text-align: center; }
  .aim-empty b { color: var(--text-hi); font-size: 13.5px; }
  .aim-empty span { font-size: 12px; }

  /* Setups score (mock 3): hit rate over the checked calls, targets vs stops bar. */
  .aim-hit { display: flex; flex-direction: column; gap: 8px; padding: 12px; color: var(--text-md); }
  .aim-hit__top { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: 13px; }
  .aim-hit__top > b { font: 700 17px var(--mono); }
  .aim-hit__top > b.up { color: var(--bull); }
  .aim-hit__top > b.down { color: var(--bear); }
  .aim-hit__top > strong { display: inline-flex; align-items: center; margin-left: auto; color: var(--accent-2); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
  .aim-hit__bar { display: flex; gap: 2px; height: 6px; }
  .aim-hit__bar > i:first-child { background: var(--bull-fill); }
  .aim-hit__bar > i:last-child { flex: 1; background: var(--bear-fill); }
  .aim-hit__legend { display: flex; justify-content: space-between; color: var(--bull); font: 600 9.5px var(--mono); letter-spacing: .08em; }
  .aim-hit__legend > span:last-child { color: var(--bear); }
  .aim-hit--in { margin: 12px 0 0; padding: 12px; border-top: 1px solid var(--line); }
  .aim-live-card,
  .aim-results-card,
  .aim-agent-list,
  .aim-profile-card,
  .aim-profile-pane,
  .aim-guide-card,
  .aim-guide-steps { overflow: hidden; }
  /* List cards are full-bleed (mock 3 / 6): rows carry their own 12px inset, the card adds none. */
  body.ai-space .aim-live-card, body.ai-space .aim-results-card, body.ai-space .aim-agent-list, body.ai-space .aim-profile-pane, body.ai-space .aim-guide-card, body.ai-space .aim-guide-steps { padding: 0; }
  /* Profile card (mock 5): its rows carry the 12px inset; the generic AI .card padding doubled it and cut "Use agent". */
  body.ai-space .aim-profile-card.card { padding: 12px 0 0; }
  .aim-profile-pane[hidden] { display: none !important; }
  .aim-live-card > header { display: flex; height: 40px; padding: 0 12px; align-items: center; justify-content: space-between; background: var(--tint); color: var(--accent-2); font: 700 10px var(--mono); letter-spacing: .1em; }
  .aim-live-card > header span { display: flex; align-items: center; gap: 5px; color: var(--text-lo); font-weight: 500; }
  .aim-live-card > header i { width: 6px; height: 6px; border-radius: 50%; background: var(--bull-fill); }
  .aim-live-placeholder { padding: 20px 12px; color: var(--text-mid); font-size: 12px; text-align: center; }
  .aim-lock-line { display: grid; grid-template-columns: 15px minmax(0, 1fr) auto; gap: 8px; min-height: 36px; padding: 0 12px; align-items: center; border-top: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); background: var(--tint); color: var(--text-md); font-size: 12px; }
  .aim-lock-line .mat-ic,
  .aim-lock-line b { color: var(--text-mid); }
  .aim-results-card > header,
  .aim-agent-list > header,
  .aim-guide-card > header { display: flex; min-height: 38px; padding: 0 12px; align-items: center; justify-content: space-between; color: var(--text-hi); font: 700 10px var(--mono); letter-spacing: .1em; }
  .aim-agent-list > header span { color: var(--text-lo); font-weight: 500; }
  .aim-row-link { display: flex; min-height: 40px; padding: 0 8px 0 12px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--accent-2) !important; font-size: 12.5px; font-weight: 700; }

  .aim-own-agent { display: grid; min-height: 62px; grid-template-columns: 34px minmax(0, 1fr) auto 18px; gap: 10px; padding: 6px 8px 6px 12px; align-items: center; border: 1px solid var(--tint-line); background: var(--bg-card); }
  .aim-own-agent > .agent-jelly-avatar { width:34px; height:34px; }
  .aim-own-agent img { width: 34px; height: 34px; object-fit: cover; background: var(--tint); }
  .aim-own-agent span { min-width: 0; }
  .aim-own-agent b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .aim-own-agent b { font-size: 12.5px; }
  .aim-own-agent small { display: block; margin-top: 2px; color: var(--text-mid); font-size: 11px; line-height: 1.2; white-space: normal; }
  .aim-own-agent strong { color: var(--accent-2); font-size: 12px; }
  .aim-agent-row { display: grid; min-height: 53px; grid-template-columns: 20px 36px minmax(0, 1fr) auto 18px; gap: 8px; padding: 6px 8px 6px 12px; align-items: center; border-top: 1px solid var(--line); }
  .aim-rank { color: var(--accent-2); font: 600 11px var(--mono); }
  .aim-agent-row > span:nth-of-type(3) { min-width: 0; }
  .aim-agent-row b,
  .aim-agent-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .aim-agent-row b { font-size: 13px; }
  .aim-agent-row small { margin-top: 2px; color: var(--text-mid); font-size: 10px; }
  .aim-agent-row > strong { color: var(--bull); font: 600 13px var(--mono); text-align: right; }
  .aim-agent-row > strong small { color: var(--text-lo); font: 500 8.5px var(--mono); letter-spacing: .06em; }
  .aim-agent-row > .mat-ic { color: var(--text-off); }
  .aim-agent-more { width: 100%; min-height: 40px; }

  .aim-profile,
  .aim-guide { padding-top: 0; }
  .aim-detail-nav { display: flex; width: auto; min-height: 40px; margin: 0 -16px; padding: 0 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--bg-card); }
  .aim-detail-nav > a { display: flex; min-height: 40px; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; }
  .aim-detail-nav > button,
  .aim-detail-nav > a:last-child { width: 40px; justify-content: center; }
  .aim-profile-card { padding-top: 12px; }
  .aim-profile-id { display: flex; gap: 12px; padding: 0 12px; align-items: center; }
  .aim-profile-id > span { min-width: 0; }
  .aim-profile-id h1 { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; font-size: 17px; }
  .aim-profile-id small { display: block; margin-top: 3px; color: var(--text-mid); font-size: 11.5px; }
  .aim-specialties { display: flex; gap: 5px; padding: 6px 12px 0 72px; }
  .aim-specialties span { padding: 2px 5px; border: 1px solid var(--border); color: var(--text-mid); font: 600 8.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
  .aim-profile-card > p { margin: 12px; font-size: 13px; line-height: 1.45; }
  .aim-profile-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(96px, auto) 38px; gap: 6px; padding: 0 12px; }
  .aim-profile-actions .btn { min-width: 0; gap: 6px; white-space: nowrap; }
  .aim-profile-actions .btn { height: 40px; padding: 0 8px; }
  .aim-profile-actions .btn-icon { width: 38px; }
  .aim-profile-note { display: flex; gap: 7px; padding: 8px 12px; align-items: center; color: var(--text-mid); font-size: 11.5px; }
  .aim-profile-note .mat-ic { color: var(--text-mid); }
  .aim-profile-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
  .aim-profile-facts > span { padding: 9px 12px; border-left: 1px solid var(--line); }
  .aim-profile-facts > span:first-child { border-left: 0; }
  .aim-profile-facts small,
  .aim-profile-facts b { display: block; }
  .aim-profile-facts small { color: var(--text-lo); font: 500 9px var(--mono); letter-spacing: .08em; }
  .aim-profile-facts b { margin-top: 4px; color: var(--bull); font: 600 17px var(--mono); }
  .aim-reading-row { position: relative; display: grid; min-height: 58px; padding: 8px 36px 8px 12px; align-content: center; border-top: 1px solid var(--line); }
  .aim-reading-row:first-child { border-top: 0; }
  .aim-reading-row b { font-size: 13.5px; line-height: 1.25; }
  .aim-reading-row small { display: flex; gap: 4px; margin-top: 5px; align-items: center; color: var(--text-lo); font: 500 9.5px var(--mono); }
  .aim-reading-row > .mat-ic { position: absolute; top: 50%; right: 8px; color: var(--text-off); transform: translateY(-50%); }

  .aim-guide > h1 { margin: 8px 4px 2px; font-size: 24px; letter-spacing: -.025em; }
  .aim-guide-free { color: var(--text-mid); font-size: 11px !important; text-align: center; }
  .aim-guide-steps > div { display: grid; min-height: 63px; padding: 9px 12px; grid-template-columns: 22px minmax(0, 1fr); gap: 9px; align-items: start; border-top: 1px solid var(--line); }
  .aim-guide-steps > div:first-child { border-top: 0; }
  .aim-guide-steps > div > span { display: grid; width: 22px; height: 22px; place-items: center; background: var(--bg-card2); color: var(--text-mid); font: 600 11px var(--mono); }
  .aim-guide-steps > div:first-child > span { background: var(--accent-fill, var(--accent)); color: #fff; }
  .aim-guide-steps p { margin: 0; }
  .aim-guide-steps b,
  .aim-guide-steps small { display: block; }
  .aim-guide-steps b { font-size: 13.5px; }
  .aim-guide-steps small { margin-top: 3px; color: var(--text-mid); font: 400 12px/1.35 var(--font-ai); }
  .aim-guide-alt { align-self: center; color: var(--accent-2) !important; font-size: 12px; font-weight: 700; }

  /* The functional copilot owns the bar. Match the mobile reference geometry. */
  .cp-dock-mobile,
  .cp-mobile-bar { font-family: var(--font-ai); }
}

@media (max-width: 340px) {
  .aim-mobile { padding-right: 12px; padding-left: 12px; }
  .aim-detail-nav { margin-right: -12px; margin-left: -12px; }
  .aim-profile-actions { grid-template-columns: minmax(0, 1fr) 100px 38px; }
  .aim-dropdowns.aim-dropdowns-three { grid-template-columns: minmax(0,1.4fr) minmax(0,.72fr) minmax(0,.88fr); }
}
