/* Application shell and screens. Composes the component library; screens
   own their composition, never their own colours or radii. */

/* ================================================================ shell */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  /* Hop header: plain ground, no rule. The workspace shows in the NavPill. */
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  transition: background-color var(--t-med) var(--ease);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}
.app-header-inner {
  display: flex;
  align-items: center;
  gap: var(--s5);
  max-width: var(--page-max);
  height: var(--header);
  margin: 0 auto;
  /* Centred above the 3 px workspace line, with air on both sides of it. */
  padding: 0 max(var(--gutter), var(--safe-left)) 3px max(var(--gutter), var(--safe-right));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--r-sm);
}
.brand:hover { color: var(--ink); }
.brand img { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 0 0 1px var(--line-strong); }
.brand-word { font-size: 1.1875rem; font-weight: var(--fw-bold); letter-spacing: -0.03em; }

.app-nav { flex: 1; display: flex; justify-content: center; min-width: 0; }
.app-nav .segmented { background: transparent; border-color: transparent; gap: var(--s1); }
.app-nav .segmented-btn { padding: 0 var(--s4); min-height: 36px; }
.app-nav .segmented-btn[aria-current="page"] { background: var(--surface); }
.app-nav .segmented-btn[aria-current="page"], .app-nav-mobile .segmented-btn[aria-current="page"] {
  background: var(--mode);
  color: var(--on-mode);
  box-shadow: none;
}
.app-nav .segmented-btn[data-nav="boomerang"]:hover:not([aria-current]) .icon { color: var(--boomerang); }
.app-nav .segmented-btn[data-nav="team"]:hover:not([aria-current]) .icon { color: var(--team); }
.app-nav .segmented-btn[data-nav="transfer"]:hover:not([aria-current]) .icon { color: var(--brand); }
.app-nav-mobile { display: none; }

.app-header-tools { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); flex: none; min-width: 0; }
.conn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s2);
  color: var(--ink-3);
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}
.conn.is-offline { color: var(--danger); }
.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--s3);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-meta);
  font-weight: var(--fw-bold);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
button.plan-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.plan-chip .icon { width: 14px; height: 14px; }
.plan-chip-icon:empty { display: none; }
.plan-chip-icon { display: inline-flex; }
.plan-pro { border-color: transparent; background: var(--brand-tint); color: var(--brand); }
.plan-team { border-color: transparent; background: var(--team-tint); color: var(--team); }
.account-btn { border-radius: 50%; }
.lang-btn { gap: 4px; color: var(--ink-2); font-size: var(--fs-meta); font-weight: var(--fw-semibold); }
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-meta); }
.avatar-lg { width: 52px; height: 52px; font-size: var(--fs-xl); }

.status-banner {
  /* Stays in view under the header while scrolled: a user must not believe
     something was sent while offline. */
  position: sticky;
  top: var(--app-header-h, var(--header));
  z-index: 39;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s2) var(--gutter);
  background: var(--warn-tint);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-align: center;
}
.status-banner .icon { color: var(--warn); }

.app-main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding-block: var(--s8) var(--s12);
  padding-inline: max(var(--gutter), var(--safe-left)) max(var(--gutter), var(--safe-right));
  outline: none;
}
body.app { display: flex; flex-direction: column; }
/* The page fills the window and the footer sits at its bottom (design): the
   main area takes the room above the footer and full-height screens (entry,
   Team discovery) fill it instead of reserving calc(100dvh * var(--vz)) themselves. */
body.app { min-height: calc(100dvh * var(--vz)); }
body.app > .app-main { flex: 1 0 auto; width: 100%; display: flex; flex-direction: column; }
.app-main > .view { flex: 1 0 auto; display: flex; flex-direction: column; }
/* Phones feel like an app: the window never scrolls, so the browser bar
   stays put and there is no rubber band or pull-to-refresh at either end.
   Only the content between the header and the bottom bar scrolls, and its
   overscroll stays inside it. scrollRoot() in ui/dom.js follows this. */
@media (max-width: 759px) {
  html { overscroll-behavior: none; }
  html:has(body.app), body.app { height: 100%; overflow: hidden; }
  body.app { height: 100dvh; min-height: 0; }
  body.app > .app-main {
    flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-padding-top: 12px;
  }
  .status-banner { top: 0; }
}
/* Settings: the anchor chips sit right under the header, as in the design. */
.app-main:has(.hz-settings) { padding-top: 0; }

.app-footer { color: var(--hz-slate); font: 500 13px var(--hz-font); }
/* Under the 75 % desktop scale 13 px rendered below 10 px. */
@media (min-width: 1000px) { .app-footer { font-size: 15px; } }
.app-footer:empty { display: none; }
.app-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 max(56px, var(--safe-right)) calc(14px + var(--safe-bottom)) max(56px, var(--safe-left));
}
.app-footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.app-footer-links a { color: var(--hz-slate); text-decoration: none; }
.app-footer-links a:hover { color: var(--hz-ink); }
/* Main on desktop: 8/32/14 inside the same 1720 scaled px as header and footer. */
@media (min-width: 760px) {
  body.app > .app-main { max-width: 1720px; padding: 8px 32px 14px; box-sizing: border-box; }
}
@media (max-width: 759px) { .app-footer-inner { padding-inline: max(20px, var(--safe-left)) max(20px, var(--safe-right)); } }

.boot { display: grid; place-items: center; min-height: calc(40vh * var(--vz)); }
.view { animation: view-in var(--t-med) var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }

.workspace-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3) var(--s4);
  margin-bottom: var(--s4);
}
.workspace-title { font-size: var(--fs-xl); }
/* Same top as Connect and Team; the three steps fill the rest of the window
   on wide screens. */
.app-main:has(> * > .boomerang) { padding-block: var(--s6); }
.boomerang { display: grid; gap: var(--s5); }
@media (min-width: 1024px) {
  .boomerang { display: flex; flex-direction: column; min-height: calc(calc(100dvh * var(--vz)) - var(--app-header-h, var(--header)) - var(--s6) - var(--s6)); }
  .boomerang > .b-flow { flex: 1; }
}
@media (max-width: 640px) { .app-main:has(> * > .boomerang) { padding-block: var(--s4); } .boomerang { gap: var(--s4); } }

@media (max-width: 760px) {
  :root { --header: 52px; }
  .app-nav { display: none; }
  .app-nav-mobile {
    display: block;
    padding: 0 max(var(--gutter), var(--safe-left)) calc(var(--s3) + 3px) max(var(--gutter), var(--safe-right));
  }
  .app-nav-mobile .segmented-btn { min-height: 36px; padding: 0 var(--s2); gap: 6px; font-size: var(--fs-meta); }
  .app-header-inner { gap: var(--s3); justify-content: space-between; }
  .conn-label { display: none; }
  .conn { padding: 0 var(--s1); }
  .app-main { padding-top: var(--s5); }
  /* Large text: the word mark gives way before the header tools do. */
  .brand { flex: 0 1 auto; min-width: 0; }
  .brand img { flex: none; }
  .brand-word { min-width: 0; overflow: hidden; white-space: nowrap; }
  .lang-code { display: none; }
  .lang-btn { width: 36px; padding: 0; }
}
@media (max-width: 360px) {
  .brand-word { display: none; }
  .app-nav-mobile .segmented-btn .icon { display: none; }
}

/* =========================================================== drop & toasts */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: var(--s6);
  background: var(--scrim);
  pointer-events: none;
  animation: fade-in var(--t-fast) var(--ease);
}
.drop-overlay-card {
  display: grid;
  justify-items: center;
  gap: var(--s3);
  width: min(520px, 100%);
  padding: var(--s12) var(--s8);
  border: 2px dashed var(--mode);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--mode);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.embedded-note { border-bottom: var(--border) solid var(--line); background: var(--mode-tint); }
.embedded-inner {
  display: flex;
  gap: var(--s4);
  align-items: flex-start;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s4) var(--gutter);
}
.embedded-inner > .icon { color: var(--mode); margin-top: 2px; }
.embedded-text { flex: 1; min-width: 0; }

/* ============================================================== connect */

/* The whole first screen fits without scrolling: one surface with the QR and
   the code, the device name as one line, the other workspaces as one row. */
.app-main:has(> .connect), .app-main:has(> * > .connect) { padding-block: var(--s6); }
.connect {
  display: grid;
  gap: var(--s5);
  max-width: 920px;
  margin: 0 auto;
}
.connect-back { margin-bottom: calc(var(--s4) * -1); }
.connect-head { display: grid; gap: var(--s1); justify-items: center; text-align: center; }
.connect-promise { max-width: 72ch; color: var(--ink-2); }
.connect-lead:empty { display: none; }

/* Workspace animations (ui/art.js). Colour follows the workspace. */
.art { width: 200px; color: var(--ink-3); }
.art svg { display: block; width: 100%; height: auto; overflow: visible; }
.art-trail { fill: none; stroke: var(--mode); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 2 7; opacity: 0.5; animation: art-dash 1.6s linear infinite; }
.art-dev rect { fill: var(--surface); stroke: currentColor; stroke-width: 2.5; }
.art-dev path, .art-spark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.art-file rect { fill: var(--mode); }
.art-file path { fill: none; stroke: var(--on-mode); stroke-width: 1.6; stroke-linecap: round; }
@keyframes art-dash { to { stroke-dashoffset: -18; } }

/* Transfer: out of the phone screen, into the computer screen, and back. */
.art-transfer .art-file { offset-path: path('M27 40 Q109 -12 191 40'); offset-rotate: 0deg; animation: art-hop 3.4s cubic-bezier(.55, 0, .45, 1) infinite alternate; }
@keyframes art-hop { 0%, 14% { offset-distance: 0%; scale: 0.8; } 50% { scale: 1.15; } 86%, 100% { offset-distance: 100%; scale: 0.8; } }
.art-transfer .art-dev-a { animation: art-lit-start 6.8s ease-in-out infinite; }
.art-transfer .art-dev-b { animation: art-lit-end 6.8s ease-in-out infinite; }
@keyframes art-lit-start { 0%, 6%, 94%, 100% { color: var(--mode); } 14%, 86% { color: var(--ink-3); } }
@keyframes art-lit-end { 0%, 36%, 64%, 100% { color: var(--ink-3); } 44%, 56% { color: var(--mode); } }

/* Boomerang: one loop out and back; at the far end it turns into the result. */
.art-boomerang .art-file { offset-path: path('M41 40 C100 -12 212 -6 212 40 C212 86 100 92 41 40'); offset-rotate: 0deg; animation: art-loop 4s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes art-loop { 0%, 8% { offset-distance: 0%; scale: 0.8; } 50% { scale: 1.15; } 92%, 100% { offset-distance: 100%; scale: 0.8; } }
.art-file-convert rect { animation: art-convert 4s steps(1) infinite; }
@keyframes art-convert { 0%, 46% { fill: var(--ink-3); } 47%, 100% { fill: var(--mode); } }
.art-spark { color: var(--mode); opacity: 0; transform-origin: 212px 40px; animation: art-spark 4s ease-out infinite; }
@keyframes art-spark { 0%, 40% { opacity: 0; scale: 0.6; } 48% { opacity: 1; scale: 1; } 60%, 100% { opacity: 0; scale: 1.2; } }
.art-boomerang .art-dev-a { animation: art-lit-start 4s ease-in-out infinite; }

/* Team: the same file reaches every person; each lights up on arrival. */
.art-team .art-file { offset-rotate: 0deg; animation: art-fan 3.2s cubic-bezier(.55, 0, .45, 1) infinite; }
.art-file-1 { offset-path: path('M41 40 Q126 6 212 12'); }
.art-file-2 { offset-path: path('M41 40 L212 40'); }
.art-file-3 { offset-path: path('M41 40 Q126 74 212 68'); }
@keyframes art-fan { 0% { offset-distance: 0%; opacity: 0; scale: 0.7; } 8%, 12% { offset-distance: 0%; opacity: 1; scale: 0.8; } 68% { offset-distance: 88%; opacity: 1; scale: 1; } 80%, 100% { offset-distance: 100%; opacity: 0; scale: 0.5; } }
.art-person circle:first-child { fill: var(--surface); stroke: currentColor; stroke-width: 2.5; }
.art-person-head { fill: currentColor; }
.art-person-body { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.art-person { animation: art-arrive 3.2s ease-in-out infinite; }
@keyframes art-arrive { 0%, 64%, 100% { color: var(--ink-3); } 72%, 92% { color: var(--mode); } }

@media (prefers-reduced-motion: reduce) {
  .art *, .art-spark { animation: none !important; }
  .art-transfer .art-file, .art-team .art-file { offset-distance: 50%; }
  .art-boomerang .art-file { offset-distance: 45%; }
}
.connect-title { font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.125rem); letter-spacing: -0.028em; }
.connect-lead { max-width: 60ch; color: var(--ink-2); }
.connect-init { display: flex; align-items: center; justify-content: center; gap: var(--s3); color: var(--ink-2); padding: var(--s8) 0; }

.connect-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s6) var(--s10);
  align-items: center;
  padding: var(--s6) var(--s8);
  border: var(--border) solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
}
.pass { display: grid; gap: var(--s3); justify-items: center; }
.pass-caption { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-meta); color: var(--ink-3); }
.pass-qr {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(184px, calc(28vh * var(--vz)), 232px);
  aspect-ratio: 1;
  padding: 12px;
  border-radius: var(--r-lg);
  background: #fff;
}
.pass-qr-img { width: 100%; height: 100%; image-rendering: pixelated; }
.pass-qr-state { display: grid; justify-items: center; gap: var(--s3); padding: var(--s4); text-align: center; color: #3d4540; }
.pass-qr-state:empty { display: none; }
.pass-qr.is-expired { background: var(--surface-sunken); }
.pass-qr.is-expired .pass-qr-state { color: var(--ink-2); }
.pass-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--mode);
  pointer-events: none;
}
.pass-corner.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--r-lg); }
.pass-corner.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: var(--r-lg); }
.pass-corner.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: var(--r-lg); }
.pass-corner.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--r-lg); }

.connect-side { display: grid; gap: var(--s5); align-content: center; min-width: 0; }
.pass-code { display: grid; gap: var(--s3); justify-items: start; }
.pass-code-label { font-size: var(--fs-meta); color: var(--ink-3); }
.code-tiles { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.code-digit {
  display: grid;
  place-items: center;
  width: 44px;
  height: 54px;
  border: var(--border) solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 1.75rem;
  font-weight: var(--fw-bold);
  line-height: 1;
}
.code-gap { width: 10px; font-size: 0; }
.pass-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--mode-tint);
  color: var(--mode);
  font-size: var(--fs-meta);
  font-weight: var(--fw-semibold);
}
.pass-timer[hidden] { display: none; }
.pass-timer.is-low { background: var(--warn-tint); color: var(--warn); }
.connect-ways { display: grid; gap: var(--s2); padding-top: var(--s4); border-top: var(--border) solid var(--line); }
.connect-ways[hidden] { display: none; }
.connect-ways-label { font-size: var(--fs-meta); color: var(--ink-3); }
.connect-actions { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); margin-left: calc(var(--s3) * -1); }
/* Disclosures elsewhere (Team) keep the link-style summary. */
.connect-help summary {
  display: inline-flex;
  gap: var(--s2);
  align-items: center;
  color: var(--mode);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
  list-style: none;
}
.connect-help summary::-webkit-details-marker { display: none; }
.connect-help[open] summary { margin-bottom: var(--s3); }

.connect-phone {
  display: grid;
  gap: var(--s3);
  width: min(440px, 100%);
  margin: 0 auto;
}
.connect-phone #btn-show-qr { justify-self: center; }

/* This device: one quiet line. */
.identity-bar { display: flex; justify-content: center; }
.identity-who { display: flex; gap: var(--s2); align-items: center; min-width: 0; max-width: 100%; }
.identity-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); color: var(--ink-2); }
.identity-icon .icon { width: 16px; height: 16px; }
.identity-text { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s2); min-width: 0; line-height: var(--lh-snug); }
.identity-display { display: flex; align-items: center; gap: var(--s1); min-width: 0; }
.identity-name { font-size: var(--fs-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-form { display: flex; flex-wrap: wrap; gap: var(--s2); }
.identity-form .field-control { flex: 1 1 160px; min-height: var(--control-sm); }

/* Boomerang and Team: two equal blocks side by side, centred under the
   stage; the container only shows on hover or focus. */
.connect-routes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 440px));
  justify-content: center;
  gap: var(--s4);
}
.route-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 64px;
  padding: var(--s3) var(--s4);
  border: var(--border) solid transparent;
  border-radius: var(--r-lg);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.route-link:hover:not(:disabled), .route-link:focus-visible {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
}
.route-link:disabled { opacity: 0.55; }
.route-link > .icon { flex: none; width: 16px; height: 16px; margin-left: auto; color: var(--ink-3); }
.route-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--mode-tint); color: var(--mode); }
.route-icon .icon { width: 18px; height: 18px; }
.route-icon-team { background: var(--team-tint); color: var(--team); }
.route-icon-transfer { background: var(--brand-tint); color: var(--brand); }
.route-icon-boomerang { background: var(--boomerang-tint); color: var(--boomerang); }
.route-text { display: grid; flex: 1; min-width: 0; gap: 2px; line-height: var(--lh-snug); }
.route-text span { font-size: var(--fs-meta); color: var(--ink-3); }

@media (max-width: 860px) {
  .connect-actions .btn, .ways-details > summary { white-space: normal; height: auto; min-height: var(--control-sm); text-align: center; }
  .connect-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: var(--s5); text-align: center; }
  .connect-side, .pass-code, .team-stage .connect-side { justify-items: center; }
  .connect-actions { justify-content: center; margin-left: 0; }
}
@media (max-width: 640px) {
  .app-main:has(> .connect), .app-main:has(> * > .connect) { padding-block: var(--s4); }
  .connect { gap: var(--s4); }
  /* Boomerang and Team are already in the tabs at the top. */
  .connect-routes { display: none; }
  .pass-qr { width: min(216px, 60vw); }
  .connect-stage { border: 0; background: transparent; box-shadow: none; padding: 0; }
  .code-digit { width: 38px; height: 48px; font-size: 1.5rem; }
}
/* Short windows (small laptops): tighter rhythm, smaller QR. */
@media (min-width: 861px) and (max-height: 760px) {
  .connect { gap: var(--s4); }
  .team-stage .checks { gap: 0; }
  .connect-stage { padding: var(--s5) var(--s8); }
  .connect-title { font-size: 1.75rem; }
}

/* ============================================================= transfer */

/* A conversation with the destination: head, timeline, composer dock. The
   page scrolls; the composer stays in reach at the bottom. */
.chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 880px;
  /* Fills the window; the footer waits below it. */
  min-height: calc(calc(100dvh * var(--vz)) - var(--app-header-h, var(--header)) - var(--s8) - var(--s4));
  margin: calc(var(--s8) * -1) auto calc(var(--s12) * -1);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s6) 0 var(--s3);
}
.chat-head-end { display: flex; align-items: center; gap: var(--s2); margin-left: auto; flex: none; }
.chat-tools { display: flex; align-items: center; gap: var(--s1); }

.to-target {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  max-width: 100%;
  padding: var(--s2) var(--s3) var(--s2) var(--s2);
  border: var(--border) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
  color: var(--ink);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.to-target:hover { border-color: var(--line-strong); background: var(--surface-hover); }
.to-target.is-unset { border-style: dashed; border-color: var(--warn); }
.to-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--mode-tint); color: var(--mode); }
.to-icon .icon { width: 20px; height: 20px; }
.to-text { display: grid; min-width: 0; line-height: var(--lh-snug); }
.to-main { display: inline-flex; align-items: center; gap: var(--s2); min-width: 0; font-weight: var(--fw-bold); font-size: var(--fs-md); }
.to-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.to-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-meta); color: var(--ink-3); }
.to-status[data-tone="ok"] { color: var(--ok); }
.to-status[data-tone="warn"] { color: var(--warn); }
.to-status[data-tone="team"] { color: var(--team); }
.to-caret { flex: none; width: 16px; height: 16px; color: var(--ink-3); }
.chat.is-team .to-target { border-color: color-mix(in srgb, var(--team) 40%, var(--line)); background: var(--team-tint); }
.chat.is-team .to-icon { background: var(--surface); color: var(--team); }
.chat.is-team .to-main { color: var(--team); }
.to-target.is-fixed:hover { border-color: color-mix(in srgb, var(--team) 40%, var(--line)); background: var(--team-tint); }
h1.to-name { margin: 0; font: inherit; letter-spacing: inherit; }
.team-back { justify-self: start; margin-bottom: calc(var(--s3) * -1); }
@media (max-width: 640px) {
  #btn-team-manage { width: var(--control-sm); padding: 0; }
  #btn-team-manage span { display: none; }
}

.chat-remember {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s4);
  margin: var(--s2) 0 var(--s4);
  padding: var(--s4);
  border: var(--border) solid color-mix(in srgb, var(--mode) 30%, var(--line));
  border-radius: var(--r-lg);
  background: var(--mode-tint);
}
.chat-remember-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--mode); }
.chat-remember-text { display: grid; gap: 2px; flex: 1 1 260px; min-width: 0; }

.chat-timeline { display: flex; flex-direction: column; gap: var(--s3); flex: 1; padding: var(--s2) 0 var(--s4); }
.chat-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  align-self: center;
  max-width: 100%;
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--ink-3);
  font-size: var(--fs-meta);
  text-align: center;
}
.chat-empty { margin: auto; padding: var(--s12) var(--s4); }

.chat .items { display: flex; flex-direction: column; gap: var(--s3); }
.chat .item {
  position: relative;
  align-self: flex-start;
  width: fit-content;
  max-width: min(86%, 640px);
  min-width: min(260px, 100%);
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border: var(--border) solid var(--line);
  border-radius: var(--r-xl);
  border-bottom-left-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
  scroll-margin-bottom: calc(var(--dock-h, 140px) + var(--s4));
  scroll-margin-top: calc(var(--app-header-h, var(--header)) + 80px);
}
.chat .items > .item + .item { border-top: var(--border) solid var(--line); }
.chat .item-out, .chat .item-result {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--mode) 22%, var(--line));
  border-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-sm);
  background: color-mix(in srgb, var(--mode) 7%, var(--surface));
}
.chat .items > .item-out + .item-out, .chat .items > .item-result + .item-result { border-top-color: color-mix(in srgb, var(--mode) 22%, var(--line)); }
.chat .item[data-kind="text"] > .thumb { display: none; }
.chat .item.is-ended { box-shadow: none; }
.chat .item.appear { animation: bubble-in var(--t-slow) var(--ease); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
.chat .item-text { font-size: var(--fs-md); -webkit-line-clamp: 12; }
.chat .item-meta { gap: 2px var(--s2); }
.chat .results { background: transparent; border: 0; }

.item-status { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.item-status.is-ok { color: var(--ok); font-weight: var(--fw-semibold); }
.item-status.is-warn { color: var(--warn); font-weight: var(--fw-semibold); }
.item-status.is-danger { color: var(--danger); font-weight: var(--fw-semibold); }
.item-status.is-brand { padding: 1px var(--s2); border-radius: var(--r-pill); background: var(--mode); color: var(--on-mode); font-weight: var(--fw-bold); }

.chat .activity-ended { align-self: center; display: grid; justify-items: center; gap: var(--s3); width: 100%; border: 0; }
.chat .activity-ended summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  color: var(--ink-3);
  font-size: var(--fs-meta);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  list-style: none;
}
.chat .activity-ended summary:hover { background: var(--surface-hover); color: var(--ink-2); }
.chat .activity-ended summary::-webkit-details-marker { display: none; }
.ended-caret { transition: transform var(--t-fast) var(--ease); }
.chat .activity-ended[open] .ended-caret { transform: rotate(180deg); }
.chat .activity-ended .items { width: 100%; }
.chat .activity-ended:not([open]) > :not(summary) { display: none; }
.chat .activity-clear { margin: 0; }

.chat-dock {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  gap: var(--s2);
  padding: var(--s2) 0 calc(var(--s4) + var(--safe-bottom));
  background: linear-gradient(to top, var(--canvas) 72%, transparent);
}
.chat-status { display: grid; gap: var(--s2); }
.chat-status .activity-task:empty, .chat-status .selection-bar[hidden] { display: none; }
.chat-status .task-bar { border: var(--border) solid var(--line); border-radius: var(--r-lg); }
.chat-status .selection-bar { position: static; border: var(--border) solid var(--line); border-radius: var(--r-lg); padding-bottom: var(--s3); box-shadow: var(--shadow-raise); }

.composer {
  display: flex;
  flex-direction: column;
  border: var(--border) solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.composer:focus-within { border-color: var(--mode); box-shadow: var(--shadow-pop), 0 0 0 3px var(--focus-halo); }
.composer.is-team { border-color: color-mix(in srgb, var(--team) 55%, var(--line-strong)); }
.composer.is-team:focus-within { border-color: var(--team); box-shadow: var(--shadow-pop), 0 0 0 3px var(--team-tint); }

.composer-input {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: var(--s4) var(--s5) var(--s2);
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: var(--lh);
  resize: none;
  overflow-y: auto;
}
.composer-input:focus, .composer-input:focus-visible { outline: none; }
.composer-input::placeholder { color: var(--ink-3); }

.attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s2);
  padding: var(--s3) var(--s3) 0;
  list-style: none;
}
.attachment {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  padding: var(--s2);
  border: var(--border) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.attachment .thumb { width: 40px; height: 40px; }
.attachment.is-invalid { border-color: var(--danger); background: var(--danger-tint); }
.attachment-main { display: grid; flex: 1; min-width: 0; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.attachment-meta { font-size: var(--fs-meta); color: var(--ink-3); }
.attachment-meta.is-error { color: var(--danger); font-weight: var(--fw-semibold); }
.composer-summary { padding: var(--s2) var(--s5) 0; }
.composer-error { padding: 0 var(--s5) var(--s2); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: 0 var(--s2) var(--s2);
}
.composer-send { min-width: 7.5rem; max-width: 60%; }
.composer-send span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ttl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: var(--s2);
  color: var(--ink-3);
}
.ttl-select {
  min-height: var(--control-sm);
  padding: 0 var(--s6) 0 var(--s1);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23626a65' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 4px center / 14px;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  appearance: none;
}
.ttl-select:hover { background-color: var(--surface-hover); }
.composer-hint { text-align: center; }

.usage-line { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-meta); color: var(--ink-3); white-space: nowrap; }
.usage-line:empty { display: none; }
.usage-meter { position: relative; width: 44px; height: 5px; border-radius: var(--r-pill); background: var(--surface-sunken); overflow: hidden; }
.usage-meter > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--mode); }
.usage-text.is-empty { color: var(--danger); font-weight: var(--fw-semibold); }

/* ------------------------------------------------------------- activity */

.items { list-style: none; }
.items:empty { display: none; }
.results { background: color-mix(in srgb, var(--mode-tint) 45%, transparent); border-bottom: var(--border) solid var(--line); }

.item {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4) var(--s3) var(--s5);
}
.items > .item + .item { border-top: var(--border) solid var(--line); }
.item.appear { animation: item-in var(--t-slow) var(--ease); }
@keyframes item-in { from { opacity: 0; transform: translateY(-4px); background: var(--mode-tint); } }
.item.is-ended { opacity: 0.68; }
.item-select { flex: none; width: 18px; height: 18px; margin: 13px 0 0; accent-color: var(--mode); }
.item .thumb { margin-top: 1px; }
.item-body { display: grid; gap: 6px; flex: 1; min-width: 0; padding-top: 2px; }
.item-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s2); min-width: 0; }
.item-name { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-semibold); color: var(--ink); }
.item-size { font-size: var(--fs-meta); color: var(--ink-3); white-space: nowrap; }
.item-text {
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  color: var(--ink);
  font-size: var(--fs-base);
}
.item-text.is-muted { color: var(--ink-3); font-style: italic; }
.item-meta {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  gap: 4px var(--s2);
  font-size: var(--fs-meta);
  color: var(--ink-3);
}
.item-dir { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; overflow: hidden; }
.item-dir > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-dir .icon { width: 14px; height: 14px; }
.item-timer { white-space: nowrap; }
.item-timer.is-urgent, [data-result-exp].is-urgent { color: var(--warn); font-weight: var(--fw-semibold); }
.item-status { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.item-progress { display: grid; gap: 4px; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s1); flex: none; padding-top: 2px; }
.item-actions .btn-sm:not(.btn-icon) { padding: 0 var(--s3); }
.item-quick { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); padding-top: 2px; }
.quick-chip {
  --btn-bg: var(--mode-tint);
  --btn-fg: var(--mode);
  --btn-line: transparent;
  --btn-hover: color-mix(in srgb, var(--mode) 16%, var(--surface));
  --btn-press: color-mix(in srgb, var(--mode) 22%, var(--surface));
  border-radius: var(--r-pill);
}
.quick-chip.btn-sm { padding: 0 var(--s3) 0 var(--s2); gap: 6px; }
.quick-chip .pro-tag { height: 16px; font-size: 10px; }
/* Suggested tools only on the newest item; every card keeps its Tools menu. */
#items > .item:not(:last-child) .quick-chip:not(.quick-more) { display: none; }
.quick-more.btn-sm { padding: 0 var(--s2) 0 var(--s3); }
.quick-more { --btn-bg: transparent; --btn-fg: var(--ink-2); --btn-line: var(--line); --btn-hover: var(--surface-hover); }
.item-result .thumb { position: relative; overflow: visible; }
.thumb-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--mode);
  color: var(--on-brand);
}
.thumb-badge .icon { width: 11px; height: 11px; stroke-width: 2.2; }
.manual-copy { min-height: 96px; font-size: var(--fs-sm); }

.activity-ended { border-top: var(--border) solid var(--line); }
.activity-ended summary {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  list-style: none;
}
.activity-ended summary::-webkit-details-marker { display: none; }
.activity-ended summary .icon { transition: transform var(--t-fast) var(--ease); }
.activity-ended[open] summary .icon { transform: rotate(90deg); }
.activity-clear { margin: var(--s1) var(--s5) var(--s3); }

.task-bar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s3) var(--s5);
  border-bottom: var(--border) solid var(--line);
  background: var(--mode-tint);
  font-size: var(--fs-sm);
}
.task-bar.is-error { background: var(--danger-tint); color: var(--ink); }
.task-bar.is-error > .icon { color: var(--danger); }
.task-main { display: grid; gap: 6px; flex: 1; min-width: 0; }
.task-text { font-weight: var(--fw-medium); }
.task-bar.is-error .task-text { flex: 1; }

.selection-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-bottom));
  border-top: var(--border) solid var(--line);
  background: var(--surface);
  box-shadow: 0 -8px 20px -14px rgb(0 0 0 / 0.25);
}
.selection-copy { display: grid; }

@media (max-width: 760px) {
  .chat { margin-top: calc(var(--s5) * -1); min-height: calc(calc(100dvh * var(--vz)) - var(--app-header-h, var(--header)) - var(--s5)); }
  .chat-head { padding: var(--s3) 0 var(--s2); gap: var(--s2); }
  .to-target { flex: 1 1 auto; padding: 6px var(--s3) 6px 6px; box-shadow: none; }
  .to-icon { width: 36px; height: 36px; }
  .to-main { font-size: var(--fs-base); }
  .chat-head-end { gap: var(--s1); }
  .usage-line .usage-meter { display: none; }
  .chat-tools .btn span { display: none; }
  .chat-tools .btn { width: var(--control-sm); padding: 0; }
  .chat .item { max-width: 92%; min-width: 0; padding: var(--s3); }
  .chat .item-text { font-size: var(--fs-base); }
  .chat-remember { padding: var(--s3); }
  .chat-remember-actions { width: 100%; }
  .chat-remember-actions .btn { flex: 1 1 auto; }
  .chat-dock { padding-bottom: calc(var(--s2) + var(--safe-bottom)); }
  .composer { border-radius: var(--r-lg); }
  .composer-input { min-height: 48px; padding: var(--s3) var(--s4) var(--s1); font-size: var(--fs-base); }
  .composer-bar .btn-quiet span { display: none; }
  .composer-bar .btn-quiet { width: var(--control); padding: 0; }
  .composer-send { min-width: 0; max-width: 70%; }
  .composer-hint { display: none; }
  .attachments { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .item { flex-wrap: wrap; padding: var(--s3) var(--s3) var(--s3) var(--s4); }
  .item-body { flex-basis: calc(100% - 44px - var(--s3) - 4px); }
  .item-actions { width: 100%; justify-content: flex-start; padding-left: calc(44px + var(--s3)); }
  .item-select ~ .item-actions { padding-left: calc(44px + 18px + var(--s3) * 2); }
  .chat .item[data-kind="text"] .item-body { flex-basis: calc(100% - 4px); }
  .chat .item[data-kind="text"] .item-actions { padding-left: 0; }
  .chat .item[data-kind="text"] .item-select ~ .item-body { flex-basis: calc(100% - 18px - var(--s3) - 4px); }
}

/* ============================================================ boomerang */

.b-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s5);
  align-items: stretch;
}
.b-panel { display: flex; flex-direction: column; min-width: 0; position: relative; }
.b-panel-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: var(--border) solid var(--line); }
.b-usage { margin-left: auto; text-align: right; }
.b-usage.is-empty { color: var(--danger); }
.b-step {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--ink-2);
  font-size: var(--fs-meta);
  font-weight: var(--fw-bold);
}
.b-input.is-filled .b-step, .b-result.has-result .b-step { background: var(--mode); color: var(--on-mode); }
.b-result.has-result { border-color: color-mix(in srgb, var(--mode) 50%, var(--line)); }
.b-panel-body { display: grid; gap: var(--s4); align-content: start; flex: 1; padding: var(--s4) var(--s5) var(--s5); }
.dropzone {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: 220px;
  align-content: center;
  padding: var(--s8) var(--s4);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  color: var(--ink-2);
  text-align: center;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.dropzone:hover:not(:disabled) { border-color: var(--mode); background: var(--mode-tint); color: var(--ink); }
.dropzone-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface); color: var(--mode); box-shadow: var(--shadow-raise); }
.dropzone strong { font-size: var(--fs-md); color: var(--ink); }
.b-files { display: grid; gap: var(--s2); list-style: none; }
.b-files:empty { display: none; }
.b-text { min-height: 200px; }
.b-tools { display: grid; gap: var(--s5); }
.tool-group { display: grid; gap: var(--s2); }
.tool-source { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
/* A tool that runs with defaults plus a small button for its options. */
.tool-split { display: flex; gap: var(--s1); min-width: 0; grid-column: 1 / -1; }
.tool-split > .tool:first-child { flex: 1; min-width: 0; }
.tool-split > .tool-options { flex: none; justify-content: center; width: 44px; padding: 0; color: var(--ink-3); }
.tool-split > .tool-options:hover { color: var(--ink); }
.tool {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 48px;
  padding: var(--s2) var(--s3);
  border: var(--border) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.tool:hover { border-color: var(--mode); background: var(--mode-tint); }
.tool-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--surface-sunken); color: var(--mode); }
.tool-icon .icon { width: 17px; height: 17px; }
.tool-label { flex: 1; min-width: 0; line-height: var(--lh-snug); }
.tool-caret { width: 14px; height: 14px; color: var(--ink-3); }
.b-task:empty { display: none; }
.b-task .task-bar { border: 0; border-radius: var(--r-md); padding-left: var(--s3); }
.b-empty { padding: var(--s8) var(--s2); }
.b-result .items { margin: 0 calc(var(--s5) * -1); background: transparent; border: 0; }
.b-result .item { flex-wrap: wrap; padding-inline: var(--s5) var(--s4); }
.b-result .item-body { flex-basis: calc(100% - 44px - var(--s3)); }
.b-result .item-name { white-space: normal; overflow-wrap: anywhere; }
/* Long names shorten in the middle, keeping the end and the extension. */
.fname { display: inline-flex; min-width: 0; max-width: 100%; text-overflow: clip; }
.fname-head { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname-tail { flex: none; white-space: pre; }
.b-result .fname { display: inline; }
.b-result .fname-head { white-space: normal; overflow: visible; }
.b-result .item-actions { width: 100%; justify-content: flex-start; padding-left: calc(44px + var(--s3)); }

@media (max-width: 1023px) {
  .b-flow { grid-template-columns: 1fr; gap: var(--s3); }
  .dropzone { min-height: 120px; padding-block: var(--s4); }
  .b-flow.is-empty .b-action .b-panel-body, .b-flow.is-empty .b-result .b-panel-body { display: none; }
  .b-flow.is-empty .b-action .b-panel-head, .b-flow.is-empty .b-result .b-panel-head { border-bottom: 0; }
}
@media (max-width: 640px) {
  .b-panel-head { padding: var(--s3) var(--s4); }
  .b-panel-body { padding: var(--s3) var(--s4) var(--s4); }
  .b-result .items { margin: 0 calc(var(--s4) * -1); }
  .tool-grid { grid-template-columns: 1fr 1fr; }
}

/* ================================================================= team */

.team { display: grid; gap: var(--s6); }
.checks { display: grid; gap: var(--s2); list-style: none; }
.checks li { display: flex; gap: var(--s2); align-items: flex-start; color: var(--ink-2); }
.checks .icon { color: var(--mode); margin-top: 2px; }
.team-price-tile {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-width: 220px;
  padding: var(--s6) var(--s5);
  border-radius: var(--r-lg);
  background: var(--mode-tint);
  text-align: center;
}
.team-price-tile .team-price-main { margin-top: var(--s1); }
.team-stage .connect-side { justify-items: start; gap: var(--s4); }
.ways-details { display: inline-block; }
.ways-details > summary { list-style: none; cursor: pointer; }
.ways-details > summary::-webkit-details-marker { display: none; }
.ways-details[open] { flex-basis: 100%; display: grid; gap: var(--s3); }
.team-price-main strong { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.team-price-main span { color: var(--ink-3); }
.row-icon-brand { background: var(--mode-tint); color: var(--mode); }
.row-icon-team { background: var(--team-tint); color: var(--team); }
.team-join-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s8); }
.team-link-claim { padding-left: var(--s8); border-left: var(--border) solid var(--line); }
.team-state { max-width: 680px; }

.team-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4) var(--s5);
}
.team-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: var(--r-lg);
  background: var(--team);
  color: var(--on-team);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
}
:root[data-theme="dark"] .team-mark { color: #0d0e1f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .team-mark { color: #0d0e1f; } }
.team-header-main { display: grid; gap: var(--s3); flex: 1; min-width: 220px; }
.team-header-main h1 { font-size: var(--fs-2xl); }
.team-meter { max-width: 420px; }
.team-sheet { display: grid; gap: var(--s6); max-width: 960px; padding: var(--s6) var(--s8) var(--s8); }
.team-panel { display: grid; gap: var(--s8); padding-top: var(--s2); }
.team-section { display: grid; gap: var(--s3); }
.team-section-head { display: grid; gap: 2px; }
.team-facts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); list-style: none; color: var(--ink-3); font-size: var(--fs-meta); }
.team-facts strong { color: var(--ink); font-size: var(--fs-md); }
.seats-row .field-control { max-width: 120px; flex: none; }
.invite-head { display: flex; gap: var(--s3); align-items: center; }
.invite-head .team-mark { width: 40px; height: 40px; font-size: var(--fs-md); border-radius: var(--r-md); }

@media (max-width: 900px) {
  .team-join-grid { grid-template-columns: 1fr; gap: var(--s6); }
  .team-link-claim { padding: var(--s6) 0 0; border-left: 0; border-top: var(--border) solid var(--line); }
}
@media (max-width: 640px) {
  .team-cta { width: 100%; }
  .team-cta .btn { flex: 1 1 100%; }
  /* The first screen on a phone: what it is, the price and the way in; the
     benefit list repeats the line under the title. */
  .team-stage .checks { display: none; }
  .team-sheet { padding: var(--s4); }
  .team .row { flex-wrap: wrap; }
  .team .row-end { width: 100%; justify-content: flex-start; padding-left: calc(36px + var(--s3)); }
}

/* ============================================================= settings */

.settings { max-width: 1040px; margin: 0 auto; }
.settings-head { margin-bottom: var(--s6); }
.settings-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: var(--s10); align-items: start; }
.settings-nav { position: sticky; top: calc(var(--header) + var(--safe-top) + var(--s6)); }
.settings-list { display: grid; gap: 2px; list-style: none; }
.settings-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-align: left;
}
.settings-link:hover { background: var(--surface-hover); color: var(--ink); }
.settings-link[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.settings-link[aria-current="page"] .settings-link-icon { color: var(--mode); }
.settings-link-icon { display: inline-flex; color: var(--ink-3); }
.settings-link-icon .icon { width: 18px; height: 18px; }
.settings-content { display: grid; gap: var(--s6); min-width: 0; outline: none; }
.section-head { display: grid; gap: var(--s1); }
.section-head h2 { font-size: var(--fs-xl); outline: none; }
.settings-group { display: grid; gap: var(--s2); }
.settings-group .section-title { padding-left: var(--s1); }
.settings-group .rows .row { min-height: 60px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); cursor: pointer; }
.row-link { color: var(--ink); text-decoration: none; }
.row-link:hover { background: var(--surface-hover); color: var(--ink); }
.row-link > .icon, button.row > .icon:last-child { color: var(--ink-3); }
.account-card { display: flex; align-items: center; gap: var(--s4); }
.plan-card { display: grid; gap: var(--s3); }
.settings-version { padding-left: var(--s1); }
.row-fact .row-title { font-weight: var(--fw-regular); color: var(--ink-2); line-height: var(--lh-snug); }
.settings-back { justify-self: start; margin-left: calc(var(--s2) * -1); }

@media (max-width: 640px) {
  .settings-head { margin-bottom: var(--s4); }
  .settings-layout { display: block; }
  .settings-nav { position: static; }
  .settings.is-detail .settings-nav { display: none; }
  .settings.is-detail .settings-head { display: none; }
  .settings-group .row { flex-wrap: wrap; }
  .settings-group .row-end { width: 100%; justify-content: flex-start; }
  .settings-group .row:has(.row-icon) .row-end { padding-left: calc(36px + var(--s3)); }
  .row-stack .segmented { width: 100%; }
  .row-stack .segmented label { flex: 1; display: contents; }
  .row-stack .segmented-btn { flex: 1; }
  .settings-nav .rows .row { min-height: 60px; }
  .settings-nav .rows .row > .icon:last-child { color: var(--ink-3); }
  .account-card { align-items: flex-start; }
}

/* ======================================================= return & state */

.return-card, .state-page {
  display: grid;
  justify-items: center;
  gap: var(--s3);
  max-width: 560px;
  margin: clamp(16px, calc(8vh * var(--vz)), 80px) auto 0;
  padding: var(--s10) var(--s6);
  border: var(--border) solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  text-align: center;
}
.return-card h1, .state-page h1 { outline: none; }
.return-icon, .state-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--s2);
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--ink-2);
}
.return-icon.is-active { background: var(--ok-tint); color: var(--ok); }
.return-icon.is-failed, .state-icon.is-error { background: var(--danger-tint); color: var(--danger); }
.return-icon.is-canceled, .return-icon.is-pending { background: var(--warn-tint); color: var(--warn); }
.return-actions { justify-content: center; margin-top: var(--s2); }

/* ============================================================ dialogs+ */

.pair-code-box {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  padding: var(--s5);
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
}
.pair-status { display: flex; align-items: center; gap: var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }
.pair-status.field-error { color: var(--danger); }
.scan-frame { position: relative; overflow: hidden; border-radius: var(--r-lg); background: #000; aspect-ratio: 1; max-height: calc(56vh * var(--vz)); }
.scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-reticle {
  position: absolute;
  inset: 18%;
  border: 3px solid rgb(255 255 255 / 0.9);
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 999px rgb(0 0 0 / 0.35);
}
/* Wide screens: a picture opens beside the conversation. */
.preview-pane[hidden] { display: none; }
.preview-pane {
  position: sticky;
  top: calc(var(--app-header-h, var(--header)) + var(--s6));
  display: grid;
  gap: var(--s3);
  max-height: calc(calc(100dvh * var(--vz)) - var(--app-header-h, var(--header)) - var(--s12));
  margin-top: var(--s6);
  padding: var(--s4);
  overflow: auto;
  border: var(--border) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
}
.preview-pane-head { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.preview-pane-title { display: flex; align-items: baseline; gap: var(--s2); flex: 1; min-width: 0; font-weight: var(--fw-semibold); }
.preview-pane-stage { display: grid; place-items: center; min-height: 200px; border-radius: var(--r-md); background: var(--surface-sunken); }
.preview-pane-img { max-width: 100%; max-height: calc(64vh * var(--vz)); object-fit: contain; border-radius: var(--r-sm); }
.thumb-open { cursor: zoom-in; }
@media (min-width: 1280px) {
  .chat-layout.has-preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: var(--s8); align-items: start; }
  .chat-layout.has-preview > .chat { margin-inline: 0; }
}
@media (max-width: 1279px) { .preview-pane { display: none; } }
.preview-stage { display: grid; place-items: center; min-height: 240px; border-radius: var(--r-md); background: var(--surface-sunken); }
.preview-img { max-height: calc(68vh * var(--vz)); object-fit: contain; border-radius: var(--r-sm); }
.summary { display: grid; gap: var(--s3); padding: var(--s4); border-radius: var(--r-lg); background: var(--surface-sunken); }
.summary-title { font-size: var(--fs-sm); }
.summary-list { display: grid; gap: var(--s2); }

/* Checkout: Hopzup's order summary next to Paddle's inline payment frame. */
.hz-co-dialog .dialog-body { padding-bottom: var(--s6); }
.hz-co { display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: var(--s6); align-items: start; }
.hz-co-summary {
  position: sticky; top: 0;
  display: grid; gap: var(--s4);
  padding: var(--s5); border-radius: var(--r-lg); background: var(--surface-sunken);
}
.hz-co-brand { display: flex; align-items: center; gap: 10px; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.hz-co-brand img { border-radius: 9px; }
.hz-co-lines { display: grid; gap: var(--s3); }
.hz-co-line { display: flex; justify-content: space-between; gap: var(--s3); }
.hz-co-line strong { display: block; }
.hz-co-line span { color: var(--ink-3); font-size: var(--fs-meta); }
.hz-co-line .hz-co-amount { color: var(--ink); font-size: inherit; font-weight: var(--fw-bold); white-space: nowrap; }
.hz-co-totals { display: grid; }
.hz-co-totals > div { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-top: var(--border) solid var(--line); }
.hz-co-totals dt { color: var(--ink-2); }
.hz-co-totals dd { margin: 0; white-space: nowrap; }
.hz-co-totals .hz-co-total { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.hz-co-totals .hz-co-total dt { color: var(--ink); }
.hz-co-recurring:empty { display: none; }
.hz-co-recurring, .hz-co-note, .hz-co-legal { color: var(--ink-3); font-size: var(--fs-meta); }
.hz-co-note { display: flex; gap: var(--s2); align-items: flex-start; }
.hz-co-note .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.hz-co-legal a { color: inherit; }
/* The page is zoomed to 75 % on desktop; the payment frame renders at 100 %. */
.hz-co-frame { min-height: 450px; zoom: var(--vz); }
.hz-co-loading { padding: var(--s6) 0; color: var(--ink-3); text-align: center; }
.hz-co-pane { display: grid; gap: var(--s4); align-content: start; min-width: 0; }
.hz-co-step { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.hz-co-message { padding: var(--s5); border-radius: var(--r-lg); background: var(--surface-sunken); }
.hz-co-message > p { margin: 0; color: var(--ink); }
.hz-co-demo { justify-self: start; margin: 0; }
/* Monthly / Annual, in the summary: the two plans side by side. */
.hz-co-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--r-md); background: var(--surface); }
.hz-co-switch button {
  display: grid; gap: 2px; justify-items: center; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--ink-2); font: inherit; font-weight: var(--fw-bold); cursor: pointer;
}
.hz-co-switch button small { color: var(--ink-3); font-size: var(--fs-meta); font-weight: var(--fw-regular); }
.hz-co-switch button[aria-checked="true"] { background: var(--hz-ink); color: var(--hz-on-ink); }
.hz-co-switch button[aria-checked="true"] small { color: inherit; opacity: 0.8; }
.hz-co-switch button:focus-visible { outline: 2px solid var(--focus, var(--hz-coral)); outline-offset: 2px; }
.hz-signin .hz-code-input { width: 100%; }
.hz-signin-links { justify-content: space-between; }
/* Desktop renders at 75 %: the summary keeps readable sizes. */
@media (min-width: 1000px) {
  .hz-co { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .hz-co-summary > * { zoom: 1.2; }
  /* The step beside it (email, code, messages) at the same reading size;
     the payment frame has its own 100 % zoom. */
  .hz-co-pane > :not(.hz-co-frame) { zoom: 1.25; }
}
@media (max-width: 760px) {
  .hz-co { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .hz-co-summary { position: static; padding: var(--s4); gap: var(--s3); }
}
.summary-list > div { display: flex; justify-content: space-between; gap: var(--s4); font-size: var(--fs-sm); }
.summary-list dt { color: var(--ink-3); }
.summary-list dd { margin: 0; text-align: right; font-weight: var(--fw-semibold); }
.legal-links a { color: var(--ink-2); }
.price-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.price-pair > div { display: grid; gap: 2px; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-sunken); }
.price-pair strong { font-size: var(--fs-xl); }
.limit-countdown { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--warn-tint); font-weight: var(--fw-semibold); }
.sheet-menu { display: grid; gap: 2px; margin: 0 calc(var(--s3) * -1); }
.sheet-menu .menu-item { min-height: 48px; font-size: var(--fs-base); }
.dialog-menu .dialog-foot { display: none; }
.order-list { display: grid; gap: var(--s2); list-style: none; }
.order-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border: var(--border) solid var(--line); border-radius: var(--r-md); }
.order-index { width: 1.5em; text-align: center; color: var(--ink-3); font-weight: var(--fw-bold); }
.order-thumb { width: 44px; height: 44px; flex: none; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-sunken); }
.order-thumb.is-file { display: grid; place-items: center; font-size: 10px; font-weight: var(--fw-bold); text-transform: uppercase; color: var(--ink-3); }
.order-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.order-tools { display: flex; gap: 2px; }
.qa-editor-stage { display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface-sunken); overflow: hidden; }
.qa-editor-canvas { max-width: 100%; max-height: calc(56vh * var(--vz)); touch-action: none; cursor: crosshair; }
.qa-editor-tools { align-items: flex-end; }
.qa-editor-control { min-width: 180px; }
.qa-ocr-text { min-height: 240px; font-size: var(--fs-sm); line-height: var(--lh); }

@media (max-width: 640px) {
  .order-row { flex-wrap: wrap; }
  .order-tools { width: 100%; justify-content: flex-end; }
  .price-pair { grid-template-columns: 1fr; }
}

/* Touch: the header tabs take a 44 px tap too (after the layout rules above). */
@media (pointer: coarse) {
  .app-nav .segmented-btn, .app-nav-mobile .segmented-btn { min-height: 44px; }
}

/* Phones on their side: a compact header leaves room for the conversation. */
@media (orientation: landscape) and (max-height: 500px) {
  .app-header-inner { height: 44px; }
  .brand-word, .composer-hint { display: none; }
}
