/* Connect AI (setup steps, token disclosure, connected apps) and the app sign-in screens. Uses style.css tokens. */

/* Tabs carry the app's 16px mark before the name. */
.connect .seg-tab { display: inline-flex; align-items: center; gap: 6px; }
.connect .seg-tab .logo { flex: none; }
.connect .seg-tab .logo-app { color: var(--muted); }
/* Phone: four tabs with marks do not fit one row, so they sit two by two (the indicator slides in both directions). */
@media (max-width: 480px) {
  .connect .seg-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: stretch; border-radius: 18px; }
  .connect .seg-tab { justify-content: center; padding: 0 10px; }
}

/* Numbered setup steps: one number circle per step, text on one left edge. */
.num-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.num-steps > li { counter-increment: step; position: relative; padding-left: 32px; min-width: 0; line-height: 22px; }
.num-steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 999px;
  background: var(--soft); color: var(--ink); font: 600 12px/22px var(--font); text-align: center; }
.step-code { display: flex; align-items: flex-start; gap: 4px; margin-top: 6px; padding: 4px 4px 4px 12px; border-radius: var(--r-sm); background: var(--soft); min-width: 0; }
.step-code-text { flex: 1 1 auto; min-width: 0; font: 13px/1.55 var(--mono); overflow-wrap: break-word; padding: 6px 0; }
.step-code-text .nw { white-space: nowrap; }
.tab-panel > .connect-note { margin-top: 12px; }

/* "Or use a token": a quiet disclosure under the Claude Code steps. The chevron turns on open; the card's height
   eases on the spring (oauth.js). */
.token-more { margin-top: 14px; border-top: 1px solid var(--hair); padding-top: 12px; }
.token-sum { display: inline-flex; align-items: center; gap: 6px; height: 30px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; list-style: none; border-radius: 999px; transition: color .18s ease-out; }
.token-sum::-webkit-details-marker { display: none; }
.token-sum:hover, .token-more[open] .token-sum { color: var(--ink); }
.token-sum:focus-visible { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }
.token-chev { flex: none; transition: transform .2s cubic-bezier(.22, 1, .36, 1); }
.token-more[open] .token-chev { transform: rotate(90deg); }
.token-body { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.token-body .connect-note { margin: 0; }

/* Connected apps: one row per app, name and dates truncate, Disconnect never wraps. */
.apps h2 { margin: 0 0 8px; }
.apps-list { list-style: none; margin: 0; padding: 0; }
.app-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hair); }
.app-row:first-child { border-top: 0; padding-top: 4px; }
.app-tile { flex: none; width: 34px; height: 34px; border-radius: 11px; background: var(--soft); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; }
.app-main { flex: 1 1 auto; min-width: 0; }
.app-name { margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-meta { margin: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apps-empty { margin: 0; font-size: 14px; }
/* Phone: the two dates go on their own lines instead of cutting off "Last used". */
@media (max-width: 480px) { .app-meta { white-space: normal; } .app-meta span:not(.app-sep) { display: block; } .app-sep { display: none; } }

/* App sign-in screens (oauth.html): the sign-in card, with an icon tile above the title. */
.oauth h1 { margin-bottom: 4px; }
.oauth-last { margin: 0; }
.oauth-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0 20px; padding: 16px; border-radius: var(--r-sm); background: var(--soft); }
.oauth-h { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.oauth-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.oauth-list li { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.oauth-list svg { flex: none; margin-top: 3px; }
.oauth-yes { color: var(--ok); }
.oauth-no { color: var(--muted); }
.oauth-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 480px) { .oauth-lists { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .token-sum, .token-chev { transition: none; } }

/* Connect header (oauth.html link_head): app mark, line, TradingAgents mark, 48px tiles. */
.link-head { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 12px 0 18px; }
.link-tile { flex: none; width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--hair); background: var(--canvas);
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.link-tile-ta .brand-mark { transform: scale(1.36); }
.link-line { position: relative; flex: none; width: 104px; height: 2px; border-radius: 2px; background: var(--hair); }
.link-line::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--ok); transform: scaleX(0); transform-origin: left; }
.link-dot { position: absolute; left: 0; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: var(--info); opacity: 0; display: none; }
.link-check { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: var(--ok); color: #fff; display: none; align-items: center; justify-content: center; }
.link-host { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }
.link-text { margin: 0 0 32px; font-size: 14px; font-weight: 600; color: var(--muted); text-align: center; }
/* Waiting: three crisp dots travel the full line from the app to TradingAgents, a third of a loop apart (negative
   delays, so they are spread from the first frame), 2.0s ease-in-out loop. */
.link-waiting .link-dot { display: block; animation: link-flow 2s ease-in-out infinite; }
.link-waiting .link-dot:nth-child(2) { animation-delay: -.667s; }
.link-waiting .link-dot:nth-child(3) { animation-delay: -1.333s; }
@keyframes link-flow { 0% { transform: translateX(0); opacity: 0; } 20%, 75% { opacity: 1; } 100% { transform: translateX(98px); opacity: 0; } }
/* Done: the line fills green left to right, then the check pops in. Once. */
.link-done .link-line::before { animation: link-fill .32s cubic-bezier(.22, 1, .36, 1) forwards; }
.link-done .link-check { display: inline-flex; opacity: 0; animation: link-pop .26s cubic-bezier(.22, 1, .36, 1) .28s forwards; }
@keyframes link-fill { to { transform: scaleX(1); } }
@keyframes link-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
/* Broken (cancelled, expired): a gap in the middle of the line, both ends dimmed. Still. */
.link-broken .link-line { background: linear-gradient(90deg, var(--hair) 0 38%, transparent 38% 62%, var(--hair) 62%); }
.link-broken .link-tile { opacity: .55; }
@media (prefers-reduced-motion: reduce) {
  .link-waiting .link-dot { display: none; animation: none; }
  .link-done .link-line::before { animation: none; transform: scaleX(1); }
  .link-done .link-check { animation: none; opacity: 1; }
}

/* Sign-in page and every app sign-in screen: the card sits in the middle of the screen. The header keeps its place;
   main fills the rest and centres the card, with bottom padding equal to the header's height so the card is centred
   on the whole screen. A card taller than the screen grows main, so the page scrolls from the top with nothing cut off. */
.wrap:has(> main > .card.narrow) { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: 0; }
.wrap:has(> main > .card.narrow) > main { flex: 1 0 auto; justify-content: center; padding: 16px 0 88px; }
main > .card.narrow { margin: 0 auto; }

/* Result screens (Done, Cancelled, Expired): the heading sits 30px under the logo row, and it and its line are
   centred under the row. */
.link-head + h1 { margin-top: 30px; }
.oauth-done h1, .oauth-cancelled h1, .oauth-expired h1, .oauth-last { text-align: center; }
