/*
 * Token contract: palette, typeface and shadows come from the generated Attio
 * overlay; shared scale, weight, radius and line-height values use canonical
 * Nimble tokens. Remaining literals preserve mapped AdminNav/record geometry,
 * breakpoints, or half-step values that neither token source declares.
 */
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--attio-surface);
  color: var(--attio-text);
  font-family: var(--attio-font);
  font-size: var(--attio-body);
  line-height: var(--nimble-line-height-normal);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}
button, textarea, select { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, summary:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: var(--nimble-focus-ring-width) solid var(--attio-accent);
  outline-offset: var(--nimble-focus-ring-offset);
}

/* Compact desktop rail and a flexible, padded main pane. */
.admin-shell { display: flex; min-height: 100vh; }
.workspace-nav {
  display: flex;
  width: 198px;
  flex: 0 0 198px;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--attio-border);
  background: var(--attio-bg);
}
.workspace-nav-header { display: contents; }
.workspace-wordmark {
  display: block;
  margin: var(--nimble-space-6) var(--nimble-space-4) var(--nimble-space-4-5);
  color: var(--attio-text);
  font-size: var(--nimble-font-size-heading);
  font-weight: 650;
  letter-spacing: -.035em;
  text-decoration: none;
}
.workspace-menu-open, .workspace-menu-close, .workspace-menu-backdrop, .workspace-menu-heading { display: none; }
.workspace-menu { display: flex; min-height: 0; flex: 1; }
.workspace-menu-panel { display: flex; min-height: 0; flex: 1; flex-direction: column; padding: 0 var(--nimble-space-3) var(--nimble-space-6); }
.workspace-identity { display: grid; gap: 3px; margin: 0 var(--nimble-space-1) var(--nimble-space-4); padding: var(--nimble-space-3); border: 1px solid var(--attio-border); border-radius: var(--nimble-radius-md); }
.workspace-identity-label {
  color: var(--attio-subtle);
  font-size: var(--nimble-font-size-caption);
  font-weight: var(--nimble-font-weight-semibold);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.workspace-brand { overflow: hidden; color: var(--attio-muted); font-size: var(--nimble-font-size-meta); text-overflow: ellipsis; white-space: nowrap; }
.workspace-links { display: flex; flex: 1; flex-direction: column; gap: var(--nimble-space-1); }
.workspace-link, .workspace-nav-item {
  display: flex;
  min-height: 36px;
  align-items: center;
  padding: var(--nimble-space-2) var(--nimble-space-3);
  border: 0;
  border-radius: var(--nimble-radius-md);
  color: var(--attio-secondary);
  font-size: var(--nimble-font-size-meta);
  text-decoration: none;
}
.workspace-link:hover, .workspace-nav-item:hover { background: var(--attio-hover); color: var(--attio-text); }
.workspace-link--active { background: var(--attio-active); color: var(--attio-purpleText); font-weight: var(--nimble-font-weight-medium); }
.workspace-link--blocked { color: var(--attio-subtle); cursor: default; }
.workspace-nav-footer { margin-top: auto; padding-top: var(--nimble-space-4); border-top: 1px solid var(--attio-border); }
.workspace-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid var(--attio-border);
  border-radius: var(--nimble-radius-md);
  background: var(--attio-bg);
  color: var(--attio-secondary);
  cursor: pointer;
  font-size: var(--nimble-font-size-label);
  font-weight: var(--nimble-font-weight-medium);
}
.workspace-button:hover { background: var(--attio-hover); }
.workspace-button:disabled { cursor: default; opacity: .55; }

.workspace-main { min-width: 0; flex: 1; overflow: auto; padding: var(--nimble-space-8); }
.workspace-page { width: min(1040px, 100%); }
.workspace-page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--nimble-space-6);
  margin-bottom: var(--nimble-space-4-5);
}
.workspace-eyebrow { margin: 0 0 var(--nimble-space-1); color: var(--attio-muted); font-size: var(--nimble-font-size-meta); font-weight: var(--nimble-font-weight-medium); }
.workspace-page-header h1 { margin: 0; font-size: var(--nimble-font-size-title); font-weight: var(--nimble-font-weight-semibold); letter-spacing: -.02em; line-height: 1.25; }
.workspace-page-header p:last-child { margin: var(--nimble-space-1) 0 0; color: var(--attio-muted); font-size: var(--nimble-font-size-label); }
.workspace-page-brand { color: var(--attio-muted); font-size: 12.5px; }

/* One admin-style record replaces the separate marketing intro and two-card composition. */
.workspace-record {
  overflow: hidden;
  border: 1px solid var(--attio-border);
  border-radius: var(--nimble-radius-lg);
  background: var(--attio-bg);
  box-shadow: var(--attio-shadow-card);
}
.workspace-chat { min-width: 0; }
#hosted-fly-chat { min-height: 500px; }
.workspace-loading { margin: 0; padding: var(--nimble-space-6); color: var(--attio-muted); font-size: 13.5px; }

/* Existing Fly renderer inside the record primitive. */
.workspace-chat .nimble-gethelp { display: flex; min-height: 500px; flex-direction: column; }
.workspace-chat .nimble-gethelp__header {
  display: flex;
  align-items: flex-start;
  gap: var(--nimble-space-2-5);
  min-height: 86px;
  padding: var(--nimble-space-4) var(--nimble-space-5);
  border-bottom: 1px solid var(--attio-border);
  background: var(--attio-tint);
}
.workspace-chat .nimble-fly-avatar { display: inline-flex; flex: 0 0 auto; }
.workspace-chat .nimble-fly-avatar__svg { color: var(--attio-blueText); }
.workspace-chat .nimble-gethelp__title { font-size: var(--nimble-font-size-subheading); font-weight: var(--nimble-font-weight-semibold); letter-spacing: -.005em; }
.workspace-chat .nimble-gethelp__subtitle { max-width: 680px; margin-top: 3px; color: var(--attio-muted); font-size: 12.5px; }
.workspace-chat .nimble-gethelp__list {
  display: flex;
  min-height: 290px;
  max-height: 520px;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--nimble-space-2);
  overflow-y: auto;
  padding: var(--nimble-space-4-5) var(--nimble-space-5);
}
.workspace-chat .nimble-gethelp-msg {
  max-width: min(78%, 680px);
  padding: 9px 11px;
  border-radius: var(--nimble-radius-sm-alt);
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.workspace-chat .nimble-gethelp-msg--fly { align-self: flex-start; background: var(--attio-hover); color: var(--attio-text); }
.workspace-chat .nimble-gethelp-msg--merchant { align-self: flex-end; background: var(--attio-text); color: var(--attio-bg); }
.workspace-chat .nimble-gethelp-msg--team { align-self: flex-start; background: var(--nimble-color-escalation-surface); color: var(--nimble-color-escalation-text); }
.workspace-chat .nimble-gethelp-msg__sender { margin-bottom: 3px; font-size: var(--nimble-font-size-caption); font-weight: var(--nimble-font-weight-semibold); opacity: .72; }
.workspace-chat .nimble-gethelp__input { display: flex; align-items: end; gap: var(--nimble-space-2); padding: var(--nimble-space-3-5) var(--nimble-space-5) var(--nimble-space-2); border-top: 1px solid var(--attio-border); }
.workspace-chat .nimble-gethelp__textarea {
  min-height: var(--nimble-control-height);
  flex: 1 1 auto;
  resize: vertical;
  padding: 9px var(--nimble-space-2-5);
  border: 1px solid var(--attio-strong);
  border-radius: var(--nimble-radius-md);
  background: var(--attio-bg);
  color: var(--attio-text);
  font-size: 13.5px;
}
.workspace-chat .nimble-gethelp__send {
  min-height: var(--nimble-control-height);
  padding: 0 var(--nimble-space-3-5);
  border: 1px solid var(--attio-text);
  border-radius: var(--nimble-radius-md);
  background: var(--attio-text);
  color: var(--attio-bg);
  cursor: pointer;
  font-size: var(--nimble-font-size-label);
  font-weight: var(--nimble-font-weight-semibold);
}
.workspace-chat .nimble-gethelp__send:hover { background: var(--attio-secondary); }
.workspace-chat .nimble-gethelp__send:disabled { cursor: default; opacity: .5; }
.workspace-chat .nimble-gethelp__status { min-height: 29px; padding: 0 var(--nimble-space-5) var(--nimble-space-2-5); color: var(--attio-muted); font-size: var(--nimble-font-size-meta); }
.workspace-chat .nimble-gethelp__status--err { color: var(--nimble-color-danger-text); }
.workspace-chat .nimble-gethelp-brief { display: contents; }
.workspace-chat .nimble-gethelp-brief__chips { display: flex; flex-wrap: wrap; gap: var(--nimble-space-1-5); }
.workspace-chat .nimble-fly-chip {
  min-height: 28px;
  padding: 0 var(--nimble-space-2);
  border: 1px solid var(--attio-border);
  border-radius: var(--nimble-radius-sm);
  background: var(--attio-bg);
  color: var(--attio-secondary);
  font: inherit;
  font-size: var(--nimble-font-size-label);
}
.workspace-retry { margin-left: var(--nimble-space-2); border: 0; background: transparent; color: var(--attio-blueText); cursor: pointer; font-weight: var(--nimble-font-weight-semibold); text-decoration: underline; }

/* Setup controls are shown on the hosted Tasks page. */
body #hosted-onboarding { display: grid; gap: var(--nimble-space-2); padding: var(--nimble-space-4-5) var(--nimble-space-5) 22px; border: 0; border-radius: 0; background: var(--attio-bg); }
#hosted-onboarding:empty::before { display: block; color: var(--attio-muted); content: "Loading setup…"; font-size: 13.5px; }
#hosted-onboarding > h2 { margin: 0; font-size: var(--nimble-font-size-subheading); font-weight: var(--nimble-font-weight-semibold); }
#hosted-onboarding > p { margin: 0; color: var(--attio-muted); font-size: 12.5px; }
#hosted-onboarding > .ws-button { justify-self: start; margin-top: 2px; }
#hosted-onboarding .setup-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--nimble-space-2); margin: var(--nimble-space-1) 0 0; padding: 0; list-style: none; }
#hosted-onboarding .setup-task { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: var(--nimble-space-2); min-width: 0; }
#hosted-onboarding .setup-task .ws-card__body { min-width: 0; }
#hosted-onboarding .setup-task p { margin: var(--nimble-space-1) 0; }
#hosted-onboarding label { display: block; margin-top: var(--nimble-space-2); }

@media (max-width: 767px) {
  .admin-shell { display: block; }
  .workspace-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: block;
    width: 100%;
    height: 49px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--attio-border);
  }
  .workspace-nav-header { display: flex; height: 48px; align-items: center; justify-content: space-between; padding: 0 var(--nimble-space-4); }
  .workspace-wordmark { margin: 0; font-size: var(--nimble-font-size-lg); }
  .workspace-menu-open, .workspace-menu-close {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 0;
    border-radius: var(--nimble-radius-sm);
    background: transparent;
    color: var(--attio-secondary);
    cursor: pointer;
  }
  .workspace-menu-open { margin-right: -8px; }
  .workspace-menu-close { margin-right: -8px; }
  .workspace-menu-open:hover, .workspace-menu-close:hover { background: var(--attio-hover); }
  .workspace-menu {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    min-height: 100vh;
  }
  .workspace-menu.is-open { display: flex; }
  .workspace-menu-backdrop {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, .4);
    cursor: default;
  }
  .workspace-menu-panel {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    width: 288px;
    max-width: 85vw;
    height: 100vh;
    padding: var(--nimble-space-6) var(--nimble-space-4);
    background: var(--attio-bg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);
  }
  .workspace-menu-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--nimble-space-6); }
  .workspace-wordmark--panel { display: block; }
  .workspace-identity { padding: 0 var(--nimble-space-3); }
  .workspace-links { min-height: 0; overflow-y: auto; }
  .workspace-nav-footer { margin-top: auto; }
  .workspace-main { padding: var(--nimble-space-5) var(--nimble-space-4) var(--nimble-space-10); }
  .workspace-page-header { align-items: flex-start; }
  .workspace-page-brand { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .workspace-chat .nimble-gethelp__list { max-height: none; }
  #hosted-onboarding .setup-list { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .workspace-main { padding-right: var(--nimble-space-3); padding-left: var(--nimble-space-3); }
  .workspace-page-header { display: block; }
  .workspace-page-brand { display: block; max-width: 100%; margin-top: var(--nimble-space-2); }
  .workspace-chat .nimble-gethelp__header { padding: var(--nimble-space-3-5) var(--nimble-space-4); }
  .workspace-chat .nimble-gethelp__list { min-height: 260px; padding: var(--nimble-space-4); }
  .workspace-chat .nimble-gethelp__input { padding-right: var(--nimble-space-4); padding-left: var(--nimble-space-4); }
  .workspace-chat .nimble-gethelp__status { padding-right: var(--nimble-space-4); padding-left: var(--nimble-space-4); }
  .workspace-chat .nimble-gethelp-msg { max-width: 92%; }
  body #hosted-onboarding { padding: var(--nimble-space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* NIM-4029: the hosted conversation owns the available viewport. These rules
 * never load in the embedded Get Help pane. Only the transcript can grow. */
html:has(.hosted-fly-home), body.hosted-fly-home { height: 100%; min-height: 0; overflow: hidden; }
.hosted-fly-home .admin-shell { height: 100vh; height: 100dvh; min-height: 0; }
.hosted-fly-home .workspace-main { display: flex; min-height: 0; overflow: hidden; padding-bottom: var(--nimble-space-3); }
.hosted-fly-home .workspace-page,
.hosted-fly-home .workspace-record,
.hosted-fly-home .workspace-chat,
.hosted-fly-home #hosted-fly-chat,
.hosted-fly-home .nimble-gethelp {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.hosted-fly-home .workspace-page { max-width: 1040px; margin-inline: auto; }
.hosted-fly-home .workspace-page-header,
.hosted-fly-home .nimble-gethelp__header,
.hosted-fly-home .nimble-gethelp__input,
.hosted-fly-home #gethelp-status { flex-shrink: 0; }
.hosted-fly-home .nimble-gethelp__list { min-height: 0; max-height: none; overscroll-behavior: contain; overflow-anchor: none; }
.hosted-fly-home .nimble-gethelp__list > * { flex-shrink: 0; }
.hosted-fly-home .nimble-gethelp__textarea { min-width: 0; max-height: 96px; resize: none; }
.hosted-fly-home #gethelp-status:empty { display: none; }
.hosted-fly-home #gethelp-status { min-height: 0; overflow-wrap: anywhere; }
.hosted-fly-home [data-typing="true"] { margin-top: auto; }
@media (max-width: 767px) {
  .hosted-fly-home .admin-shell { display: flex; flex-direction: column; }
  .hosted-fly-home .workspace-nav { flex: 0 0 49px; }
  .hosted-fly-home .workspace-main { padding-top: var(--nimble-space-3); }
  .hosted-fly-home .workspace-page-header { margin-bottom: var(--nimble-space-2); }
  .hosted-fly-home .workspace-page-header p:last-child,
  .hosted-fly-home .nimble-gethelp__subtitle { display: none; }
  .hosted-fly-home .nimble-gethelp__header { min-height: 0; align-items: center; }
  .hosted-fly-home .workspace-page-brand { margin-top: 0; }
}

/* Fly children share one group on every hosted surface. */
.workspace-fly-heading { display: block; padding: var(--nimble-space-2) var(--nimble-space-3); color: var(--attio-muted); font-weight: var(--nimble-font-weight-semibold); }
.workspace-fly-children { display: grid; gap: var(--nimble-space-1); padding-left: var(--nimble-space-3); }
.hosted-fly-home .fly-setup-progress { flex-shrink: 0; padding: var(--nimble-space-1) var(--nimble-space-5); color: var(--attio-blueText); font-size: var(--nimble-font-size-meta); }
.fly-setup-progress[hidden] { display: none; }
