/* ============================================================================
   3-PANE CLINICAL WORKBENCH & PERSISTENT QUERY COPILOT DRAWER
   Left Rail (slim collapsible desktop + default-collapsed mobile drawer),
   Center Canvas (Today's Focus + practice deck), and Right Dockable Query
   Copilot Drawer (Cmd+K on desktop, floating bottom pill -> Bottom Sheet on
   mobile < 1024px).
   ============================================================================ */

/* ---- 3-Pane Desktop Grid & Slim Collapsible Left Rail ------------------- */
.app-shell--workbench {
  transition: grid-template-columns 0.18s ease, max-width 0.18s ease;
}

@media (min-width: 1024px) {
  .app-shell--workbench.is-sidebar-collapsed:not(.app-shell--focus) {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 24px;
  }

  .app-shell--workbench.is-copilot-open:not(.app-shell--focus) {
    max-width: 1480px;
    grid-template-columns: 236px minmax(0, 1fr) 368px;
    gap: 24px;
  }

  .app-shell--workbench.is-sidebar-collapsed.is-copilot-open:not(.app-shell--focus) {
    max-width: 1480px;
    grid-template-columns: 74px minmax(0, 1fr) 368px;
    gap: 20px;
  }

  .app-shell--workbench.app-shell--focus.is-copilot-open {
    max-width: 1440px;
    grid-template-columns: minmax(0, 1fr) 368px;
    gap: 24px;
  }

  .app-shell--workbench.is-sidebar-collapsed .app-sidebar {
    overflow: hidden;
  }

  .app-shell--workbench.is-sidebar-collapsed .app-logo__text,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__label,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__count,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__heading,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__studio-text,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__studio-badge,
  .app-shell--workbench.is-sidebar-collapsed .app-track,
  .app-shell--workbench.is-sidebar-collapsed .app-account__meta,
  .app-shell--workbench.is-sidebar-collapsed .gppt-product-link small,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__auth {
    display: none;
  }

  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__head {
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 8px;
  }

  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__link,
  .app-shell--workbench.is-sidebar-collapsed .app-sidebar__studio-link {
    justify-content: center;
    padding: 10px;
  }

  .app-shell--workbench.is-sidebar-collapsed .app-account__summary {
    justify-content: center;
    padding: 8px 4px;
  }
}

.app-sidebar__collapse {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--cp-card);
  color: var(--ink-mute);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-sidebar__collapse:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.app-sidebar__collapse svg {
  width: 15px;
  height: 15px;
  transition: transform 0.18s ease;
}

.app-sidebar.is-collapsed .app-sidebar__collapse svg {
  transform: rotate(180deg);
}

@media (max-width: 1023.98px) {
  .app-sidebar__collapse {
    display: none;
  }
}

/* ---- Studio Link in Left Rail ------------------------------------------- */
.app-sidebar__studio {
  padding: 0 2px;
}

.app-sidebar__studio-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid rgba(107, 45, 123, 0.16);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--cp-card));
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.app-sidebar__studio-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.app-sidebar__studio-link .dashboard-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--accent);
}

.app-sidebar__studio-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--cp-card);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

/* ---- Workbench Top Utility Bar & Trigger -------------------------------- */
.wb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 2px;
}

.wb-topbar__context {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-copilot-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--cp-card);
  color: var(--ink);
  font: 800 13px/1 var(--font-ui);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.wb-copilot-trigger:hover,
.wb-copilot-trigger.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wb-copilot-trigger__kbd {
  display: inline-grid;
  place-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--ink-mute);
  font: 700 11px/1 var(--font-ui);
}

.wb-mobile-copilot-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(107, 45, 123, 0.25);
  background: var(--accent-soft);
  color: var(--accent);
  font: 800 12.5px/1 var(--font-ui);
  cursor: pointer;
}

@media (max-width: 1023.98px) {
  .wb-topbar {
    display: none;
  }
}

/* ---- Today's Focus Hero Card on Practice -------------------------------- */
.wb-focus {
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--cp-card);
  border: 1px solid rgba(15, 23, 42, 0.09);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wb-focus__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
}

.wb-focus__copy {
  flex: 1 1 280px;
  min-width: 0;
}

.wb-focus__eyebrow {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}

.wb-focus__title {
  margin: 6px 0 0;
  font-size: clamp(19px, 2vw, 23px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.22;
  color: #0f172a;
}

.wb-focus__desc {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-mute);
  max-width: 60ch;
}

.wb-focus__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.wb-focus__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wb-focus__btn--primary {
  background: #0f172a;
  color: #ffffff !important;
}

.wb-focus__btn--primary:hover {
  background: var(--accent);
}

.wb-focus__btn--ghost {
  background: var(--paper);
  color: var(--ink-soft) !important;
  border: 1px solid var(--rule);
}

.wb-focus__btn--ghost:hover {
  border-color: var(--ink-soft);
  color: var(--ink) !important;
}

.wb-focus__gaps {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.wb-focus__gaps-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-faint);
}

.wb-focus__gap-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wb-gap-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  font: 700 12.5px/1.2 var(--font-ui);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.wb-gap-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wb-gap-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ---- Right-Side Dockable Query Copilot Drawer (Desktop) ----------------- */
.wb-copilot {
  display: none;
  flex-direction: column;
  background: var(--cp-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .wb-copilot.is-open {
    display: flex;
    position: sticky;
    top: 16px;
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
  }
}

.wb-copilot__handle {
  display: none;
}

.wb-copilot__head {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: var(--paper);
}

.wb-copilot__identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wb-copilot__title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-copilot__spark {
  color: var(--accent);
  flex: none;
}

.wb-copilot__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.wb-copilot__ctx-pill {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.wb-copilot__head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.wb-copilot__expand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--cp-card);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.wb-copilot__expand:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wb-copilot__icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cp-card);
  color: var(--ink-mute);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.wb-copilot__icon-btn:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.wb-copilot__icon-btn svg {
  width: 14px;
  height: 14px;
}

.wb-copilot__chips {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wb-copilot__chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font: 700 11.5px/1.25 var(--font-ui);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.wb-copilot__chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wb-copilot__thread {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wb-copilot__empty {
  margin: auto 0;
  padding: 16px 12px;
  text-align: center;
}

.wb-copilot__empty-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.wb-copilot__empty-sub {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-mute);
}

.wb-copilot__signin-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline;
}

.wb-copilot__msg {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.52;
  color: var(--ink);
  word-wrap: break-word;
}

.wb-copilot__msg--user {
  background: var(--accent-soft);
  border: 1px solid rgba(107, 45, 123, 0.18);
  align-self: flex-end;
  max-width: 92%;
}

.wb-copilot__msg--assistant {
  background: var(--paper);
  border: 1px solid var(--line);
}

.wb-copilot__msg-role {
  display: block;
  margin-bottom: 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.wb-copilot__msg-body p {
  margin: 0 0 8px;
}

.wb-copilot__msg-body p:last-child {
  margin-bottom: 0;
}

.wb-copilot__guest-cta {
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.wb-copilot__status {
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.wb-copilot__composer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--cp-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wb-copilot__input {
  width: 100%;
  resize: none;
  border: 1px solid var(--rule);
  border-radius: 11px;
  padding: 9px 11px;
  background: var(--paper);
  color: var(--ink);
  font: 600 13.5px/1.45 var(--font-ui);
}

.wb-copilot__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

.wb-copilot__composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wb-copilot__zdr {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
}

.wb-copilot__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff !important;
  font: 800 12.5px/1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
}

.wb-copilot__send:hover {
  background: var(--accent);
}

.wb-copilot__send:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ---- Mobile Floating Bottom Pill & Slide-Up Bottom Sheet (< 1024px) ----- */
.wb-copilot-backdrop {
  display: none;
}

.wb-copilot-fab {
  display: none;
}

@media (max-width: 1023.98px) {
  .wb-copilot-fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    right: 16px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    z-index: 45;
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font: 800 13.5px/1 var(--font-ui);
    box-shadow: 0 12px 28px -8px rgba(15, 23, 42, 0.45);
    cursor: pointer;
  }

  .wb-copilot-fab[hidden] {
    display: none;
  }

  .wb-copilot-backdrop.is-active {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 84;
    border: 0;
    background: rgba(15, 23, 42, 0.44);
    cursor: pointer;
  }

  .wb-copilot.is-open {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    max-height: 82dvh;
    height: min(82dvh, 620px);
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -16px 48px rgba(15, 23, 42, 0.28);
    animation: wb-sheet-up 0.2s ease-out;
  }

  .wb-copilot__handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 2px;
    background: var(--paper);
  }

  .wb-copilot__handle span {
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.18);
  }

  body.wb-copilot-sheet-open .app-tabbar {
    display: none;
  }
}

@keyframes wb-sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

/* Native web sheets hide workbench copilot chrome cleanly. */
.native-app .wb-topbar,
.native-app .wb-copilot,
.native-app .wb-copilot-fab,
.native-app .wb-copilot-backdrop,
.native-app .wb-mobile-copilot-btn,
.native-app .app-sidebar__studio {
  display: none !important;
}
