/* Applications stage. The window follows F2's layout; the product UI inside follows the v4 wireframes
   (white surfaces, hairline borders, 12px cards, 24px composer, 14/15/13px type scale). */

#apps {
  padding-top: 96px;
  padding-bottom: 24px;
}

#apps h2 {
  max-width: 820px;
  font-size: clamp(30px, 3.2vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.015em;
}

:where(.ap) p {
  max-width: none;
  margin: 0;
  color: inherit;
}

.ap {
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 30px 60px -44px rgba(20, 33, 61, 0.5);
}

.ap-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}

.ap-tabs,
.ap-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ap-tools {
  gap: 8px;
}

.ap-tab {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.ap-tab[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ap-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px dashed var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.ap-replay {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.ap-body {
  display: flex;
  min-height: 520px;
}

/* left rail: logo tile, then the product's outline nav icons; the current app's icon is lit */
.ap-rail {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 56px;
  padding: 14px 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.ap-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: var(--navy);
  color: var(--on-navy);
}

.ap-logo .lg-mark {
  width: 17px;
  height: 17px;
  margin-left: -2px;
  overflow: visible;
}

.ap-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--ink2);
}

.ap-nav svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ap[data-app="search"] [data-r="search"],
.ap[data-app="assistant"] [data-r="chat"],
.ap[data-app="content"] [data-r="chat"],
.ap[data-app="data"] [data-r="chat"],
.ap[data-app="chat"] [data-r="team"],
.ap[data-app="proactive"] [data-r="home"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.ap-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: clamp(16px, 2.6vw, 32px);
  font-size: 15px;
  line-height: 1.6;
}

/* the view and its invisible finished-state sizers share one grid cell (see apps.js) */
.ap-stack {
  display: grid;
  flex: 1;
  min-width: 0;
}

.ap-stack > * {
  grid-area: 1 / 1;
}

.ap-sizer {
  visibility: hidden;
}

.ap-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ap-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

/* composer: white, hairline, 24px radius; round accent send button */
.ap-bottom {
  margin-top: auto;
  padding-top: 20px;
}

.ap-composer {
  padding: 12px 14px 10px 18px;
  border: 1px solid var(--line2);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 10px 30px -22px rgba(20, 33, 61, 0.5);
}

.ap-composer-text {
  min-height: 26px;
  font-size: 15px;
  line-height: 26px;
}

.ap-ph {
  color: var(--muted);
}

.ap-composer-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
  color: var(--ink2);
  font-size: 13px;
}

.ap-plus {
  font-size: 20px;
  line-height: 1;
}

.ap-auto {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ap-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.ap-user {
  align-self: flex-end;
  width: fit-content;
  max-width: min(560px, 100%);
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--sunken);
  font-size: 15px;
}

/* "Show work": muted line, then the steps, spinner while running and a check when done */
.ap-work {
  margin-top: 16px;
  color: var(--muted);
}

.ap-work-h {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}

.ap-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0 0 0 4px;
  list-style: none;
}

.ap-step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink2);
  font-size: 13px;
}

.ap-step svg {
  flex: none;
}

.ap-answers {
  margin-top: 12px;
}

.ap-answer {
  line-height: 1.6;
}

.ap-k-h {
  margin-top: 12px;
  font-size: 15px;
  font-weight: 600;
}

.ap-k-p {
  margin-top: 6px;
  font-size: 15px;
}

.ap-k-strong {
  font-size: 16px;
  font-weight: 600;
}

.ap-k-li {
  margin-top: 6px;
  padding-left: 14px;
  font-size: 15px;
}

.ap-k-sugg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--sunken);
  color: var(--ink2);
  font-size: 14px;
}

.ap-bullet {
  margin-left: -14px;
  margin-right: 6px;
  color: var(--accent);
}

/* citation chip: small grey number, as in the wireframes */
.ap-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--sunken);
  color: var(--ink2);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 2px;
}

.ap-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: apCaret 1s steps(1) infinite;
}

.ap-spin {
  animation: apSpin 0.9s linear infinite;
  transform-origin: 50% 50%;
}

@keyframes apCaret {
  50% { opacity: 0; }
}

@keyframes apSpin {
  to { transform: rotate(360deg); }
}

.ap-n {
  color: var(--accent);
  font-weight: 600;
}

.ap-lede {
  margin-top: 14px;
  color: var(--ink2);
  font-size: 14px;
}

/* search */
.ap-searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 18px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 10px 30px -22px rgba(20, 33, 61, 0.5);
}

.ap-searchbar svg {
  flex: none;
}

.ap-searchtext {
  flex: 1;
  min-width: 0;
  font-size: 16px;
}

.ap-askchip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 12px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.ap-people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 16px;
  margin-top: 14px;
}

.ap-person {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.ap-who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ap-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 24px;
}

.ap-role {
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.ap-avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
}

.ap-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.ap-tone-seal { background: var(--seal-soft); color: var(--seal); }
.ap-tone-accent { background: var(--accent-soft); color: var(--accent); }
.ap-tone-sunken { background: var(--sunken); color: var(--ink2); }

.ap-srcs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.ap-src {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink2);
  font-size: 12px;
  line-height: 1.4;
}

.ap-appicon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* assistant: answer column and sources panel */
.ap-split {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 20px;
}

.ap-split > .ap-col {
  flex: 2 1 420px;
}

.ap-side {
  flex: 1 1 260px;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.ap-side-h {
  font-size: 14px;
  font-weight: 600;
}

.ap-side-h span {
  color: var(--muted);
  font-weight: 400;
}

.ap-srclist {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.ap-srcrow {
  display: flex;
  gap: 10px;
}

.ap-srcrow .ap-appicon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.ap-srctitle {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.ap-srcsys {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

/* content creation */
.ap-slides {
  display: grid;
  /* five columns when they fit, else 150px ones; auto-fill so a slide drafted alone keeps its finished size */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, max(150px, (100% - 40px) / 5)), 1fr));
  gap: 10px;
  margin-top: 16px;
}

.ap-slide {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  aspect-ratio: 16 / 10;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.ap-slide[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ap-slide-n {
  color: var(--muted);
  font-size: 11px;
}

.ap-slide-t {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 18px;
  line-height: 1.2;
}

.ap-slide-r {
  color: var(--accent);
  font-size: 11px;
}

.ap-detail {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ap-detail-h {
  color: var(--muted);
  font-size: 13px;
}

.ap-detail-b {
  margin-top: 4px;
  font-size: 16px;
}

/* team chat */
.ap-channel {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.ap-msgs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ap-msg {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: end;
  gap: 4px 10px;
}

.ap-msg .ap-avatar {
  margin-bottom: 6px; /* centred on a one-line bubble, on the last line of a longer one */
}

.ap-msg-name {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.ap-msg-text {
  width: fit-content;
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--sunken);
  font-size: 15px;
}

.ap-mention {
  color: var(--accent);
  font-weight: 500;
}

.ap-reply {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--surface);
}

.ap-reply-h {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
}

.ap-mini-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--navy);
  color: var(--on-navy);
}

.ap-mini-logo .lg-mark {
  width: 12px;
  height: 12px;
  margin-left: -1px;
  overflow: visible;
}

.ap-owners {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.ap-owner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.ap-status {
  padding: 1px 10px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 12px;
}

.ap-status.is-agreed {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ap-status.is-proposed {
  border-color: var(--seal-line);
  background: var(--seal-soft);
  color: var(--seal);
}

/* data analysis */
.ap-figure {
  margin: 16px 0 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ap-figure figcaption {
  font-size: 15px;
  font-weight: 600;
}

.ap-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.ap-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.ap-bar-label {
  flex: 0 0 110px;
  color: var(--ink2);
  font-size: 14px;
}

.ap-bar-track {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  gap: 10px;
}

.ap-bar-fill {
  height: 18px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.ap-bar-val {
  font-size: 14px;
  font-weight: 600;
}

.ap-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink2);
  font-size: 13px;
}

.ap-notes strong {
  color: var(--ink);
}

/* proactive brief */
.ap-greeting {
  min-height: 48px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.6;
}

.ap-greeting + .ap-lede {
  margin-top: 4px;
}

.ap-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 12px;
  margin-top: 18px;
}

.ap-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.ap-card-h {
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 600;
}

.ap-card-i {
  margin-top: 6px;
  font-size: 14px;
}

.ap-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--accent-soft);
  font-size: 14px;
}

.ap-strip-h {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 600;
}

.ap-strip .ap-stack {
  flex: 1 1 auto; /* basis is the longest strip, so every tab wraps the same way */
}

@media (max-width: 520px) {
  .ap-rail {
    display: none;
  }

  .ap-side {
    padding-left: 0;
    border-left: 0;
  }

  .ap-bar-label {
    flex-basis: 100%;
  }
}
