/* Employee room: conversation control plane beside a verified observation surface. */
.employee-room {
  --room-graphite: #111318;
  --room-panel: #171a20;
  --room-rail: #20242b;
  --room-line: #292d34;
  --room-paper: #fbfbfc;
  --room-paper-line: #dfe3e8;
  --room-ink: #20232d;
  --room-muted: #687080;
  --room-mint: #34d399;
  --room-violet: #8b82e8;
  display: grid;
  position: relative;
  grid-template-columns: minmax(320px, 42fr) minmax(480px, 58fr);
  height: calc(100dvh - 104px);
  overflow: hidden;
  border: 1px solid var(--room-line);
  background: var(--room-graphite);
}

body.portal-app:has(#view-chat.active) .main {
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 16px;
}

.room-tabs {
  display: none;
}

.room-splitter {
  display: none;
}

.room-chat-panel,
.room-live-panel {
  min-width: 0;
  min-height: 0;
}

.room-chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--room-paper);
  color: var(--room-ink);
}

body.portal-app .room-chat-panel .chat-head,
body.portal-app .room-chat-panel .chat-input-bar {
  border-color: var(--room-paper-line) !important;
  background: var(--room-paper) !important;
}

.room-chat-panel .chat-input-bar {
  flex: 0 0 auto;
}

.room-chat-panel .chat-head {
  flex: 0 0 auto;
}

.room-chat-panel .chat-head-name {
  color: var(--room-ink);
}

.room-chat-panel .chat-head-status {
  color: #087553;
}

.room-chat-panel .chat-messages {
  min-height: 0;
  background: var(--room-paper);
  scrollbar-color: #b9bec7 transparent;
}

body.portal-app .room-chat-panel .chat-bubble.employee {
  border-color: #e0e4e9 !important;
  background: #f1f3f5 !important;
  color: var(--room-ink) !important;
}

body.portal-app .room-chat-panel .chat-bubble.system {
  border-color: #f2d5ba !important;
  background: #fff7ed !important;
  color: #8f3d12 !important;
}

body.portal-app .room-chat-panel .chat-work-link {
  border-color: #d9d2ff;
  border-left: 2px solid var(--room-violet);
  background: #f4f2ff;
  color: var(--room-ink);
}

body.portal-app .room-chat-panel .chat-work-link:hover {
  background: #ece9ff;
}

.room-chat-panel .chat-work-link > span:last-child {
  color: #655bc4;
}

.room-chat-panel .chat-work-dot {
  background: var(--room-violet);
}

.room-chat-panel .chat-input {
  min-width: 0;
  border-color: #cbd1da;
  background: #ffffff;
  color: var(--room-ink);
}

.room-chat-panel .chat-input::placeholder {
  color: #777f8c;
}

.room-live-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid rgba(139, 130, 232, 0.42);
  background: var(--room-panel);
  color: #f7f7f4;
}

.live-workspace-head {
  min-height: 88px;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--room-line);
  background: var(--room-panel);
}

.live-workspace-context {
  min-width: 0;
}

.live-workspace-kicker {
  display: block;
  margin-bottom: 4px;
  color: #9ea4ae;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: uppercase;
}

#liveWorkspaceObjective {
  margin-top: 2px;
  overflow: hidden;
  color: #c8ccd3;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-workspace-employee {
  display: block;
  overflow: hidden;
  color: #f7f7f4;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#liveWorkspaceApplication {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #a8aeb8;
  font-size: 0.75rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-workspace-mode {
  max-width: 100%;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  color: #9fe5c8;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-workspace-mode::before {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--room-mint);
  content: '';
}

.live-workspace-state {
  flex: 0 0 auto;
  max-width: 44%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #c8ccd3;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: right;
}

.live-workspace-state::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8e96a2;
  content: '';
}

.room-live-panel:has(#liveWorkspaceImage:not([hidden])) .live-workspace-state::before {
  background: var(--room-mint);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.live-workspace-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: #0d0f13;
}

.live-workspace-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.live-workspace-frame.is-redacted img {
  filter: blur(10px);
  transform: scale(1.02);
}

.live-workspace-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #8e96a2;
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: center;
}

.live-workspace-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  background: #08090b;
}

.live-workspace-controls {
  min-height: 65px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content repeat(5, 44px);
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--room-line);
  background: var(--room-rail);
}

.live-workspace-freshness {
  min-width: 0;
  overflow: hidden;
  color: #969da8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  letter-spacing: 0;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-live-panel:has(#liveWorkspaceImage:not([hidden])) .live-workspace-freshness {
  color: #8fe7c3;
}

.live-workspace-controls button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid #373c45;
  border-radius: 6px;
  background: #252a32;
  color: #d5d8de;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.live-workspace-controls button:hover {
  border-color: #59616d;
  background: #2b3039;
  color: #ffffff;
}

.live-workspace-controls button[data-open-support] {
  width: auto;
  padding-inline: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.live-workspace-controls button[aria-pressed='true'] {
  border-color: var(--orange-border, #d85512);
  background: var(--orange, #ff5f12);
  color: #111318;
}

.live-workspace-controls svg {
  width: 18px;
  height: 18px;
}

.room-needs-panel {
  position: absolute;
  z-index: 12;
  inset: 0 0 0 auto;
  width: min(420px, 100%);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid var(--room-paper-line);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.24);
  background: var(--room-paper);
  color: var(--room-ink);
}

.room-needs-panel[hidden] {
  display: none;
}

.room-needs-head {
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--room-paper-line);
  background: #ffffff;
}

.room-needs-head span,
.room-needs-head strong {
  display: block;
  color: var(--room-ink);
  letter-spacing: 0;
}

.room-needs-head span {
  margin-bottom: 3px;
  color: #697180;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
}

.room-needs-head strong {
  font-size: 0.9375rem;
  line-height: 1.35;
}

.room-needs-head button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d7dbe1;
  border-radius: 6px;
  background: #ffffff;
  color: #343a45;
}

.room-needs-head button:hover {
  background: #f1f3f5;
}

.room-needs-head svg {
  width: 18px;
  height: 18px;
}

.room-needs-item {
  width: 100%;
  min-height: 64px;
  padding: 13px 16px;
  display: grid;
  gap: 4px;
  border: 0;
  border-bottom: 1px solid var(--room-paper-line);
  background: transparent;
  color: var(--room-ink);
  text-align: left;
}

.room-needs-item:hover {
  background: #f1f3f5;
}

body.portal-app .room-needs-item strong {
  color: var(--room-ink);
  font-size: 0.875rem;
  line-height: 1.35;
}

.room-needs-item span,
.room-needs-empty {
  color: var(--room-muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.room-needs-item small {
  color: #7b8290;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.35;
}

.chat-empty-state {
  margin: auto;
  padding: 24px;
  color: var(--room-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: center;
}

.room-needs-empty {
  padding: 24px 16px;
}

.room-tab.has-items::after {
  width: 6px;
  height: 6px;
  margin-left: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--orange, #ff5f12);
  content: '';
  vertical-align: 2px;
}

@media (min-width: 768px) and (max-width: 1100px) {
  body.portal-app:has(#view-chat.active) .sidebar {
    transform: translateX(-100%);
  }

  body.portal-app:has(#view-chat.active) .sidebar.open {
    transform: translateX(0);
  }

  body.portal-app:has(#view-chat.active) .sidebar-close,
  body.portal-app:has(#view-chat.active) .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.portal-app:has(#view-chat.active) .topbar {
    left: 0;
  }

  body.portal-app:has(#view-chat.active) .main {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 1100px) {
  .live-workspace-controls {
    min-height: 109px;
    grid-template-columns: max-content repeat(5, 44px);
    justify-content: space-between;
  }

  .live-workspace-controls button {
    height: 45px;
    min-height: 45px;
  }

  .live-workspace-freshness {
    grid-column: 1 / -1;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}

@media (max-width: 1023px) {
  body.portal-app:has(#view-chat.active) .main {
    padding: 68px 0 0;
  }

  .employee-room {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 49px auto minmax(0, 1fr);
    height: calc(100dvh - 68px);
    min-height: 0;
    border-right: 0;
    border-left: 0;
  }

  .room-tabs {
    grid-row: 1;
    height: 49px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-bottom: 1px solid var(--room-line);
    background: var(--room-graphite);
  }

  .room-tab {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    overflow: hidden;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: #969da8;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .room-tab[aria-selected='true'] {
    border-bottom-color: var(--orange, #ff5f12);
    color: #f7f7f4;
  }

  .employee-room .room-chat-panel,
  .employee-room .room-live-panel {
    display: flex;
  }

  .room-live-panel {
    grid-row: 2;
    border-left: 0;
  }

  .live-workspace-freshness {
    font-size: 0.625rem;
  }

  .room-chat-panel {
    grid-row: 3;
  }

  .room-needs-panel {
    inset: 49px 0 0 auto;
    width: 100%;
    border-left: 0;
    box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.28);
  }

  .room-chat-panel .chat-head {
    min-height: 62px;
    padding: 12px 16px;
  }

  .live-workspace-head {
    min-height: 68px;
    padding: 9px 12px;
  }

  #liveWorkspaceObjective {
    font-size: 0.75rem;
  }

  .live-workspace-controls {
    min-height: 61px;
    padding: 8px;
    grid-template-columns: minmax(0, 1fr) max-content repeat(5, 44px);
    justify-content: stretch;
  }

  .live-workspace-freshness {
    grid-column: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

}

@media (min-width: 768px) and (max-width: 1023px) {
  .employee-room {
    grid-template-columns: minmax(310px, 42fr) minmax(0, 58fr);
    grid-template-rows: 49px minmax(0, 1fr);
  }

  .room-tabs {
    grid-column: 1 / -1;
  }

  .room-chat-panel {
    grid-column: 1;
    grid-row: 2;
  }

  .room-live-panel {
    grid-column: 2;
    grid-row: 2;
    border-left: 1px solid rgba(139, 130, 232, 0.42);
  }

  .room-needs-panel {
    width: min(420px, 100%);
    border-left: 1px solid var(--room-paper-line);
  }

  .live-workspace-freshness {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }
}

@media (max-width: 767px) {
  .employee-room {
    --room-mobile-live-height: clamp(160px, 40%, 310px);
    grid-template-rows: 49px var(--room-mobile-live-height) 32px minmax(0, 1fr);
    height: calc(100dvh - 132px - env(safe-area-inset-bottom));
  }

  .employee-room.is-resizing {
    cursor: ns-resize;
    user-select: none;
  }

  .room-live-panel {
    position: relative;
    grid-row: 2;
  }

  .room-splitter {
    position: relative;
    z-index: 4;
    grid-row: 3;
    width: 100%;
    min-width: 44px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-top: 1px solid #30353e;
    border-bottom: 1px solid #30353e;
    border-radius: 0;
    background: #1d2128;
    color: #8f97a3;
    cursor: ns-resize;
    touch-action: none;
  }

  .room-splitter::before,
  .room-splitter::after {
    position: absolute;
    left: 50%;
    width: 28px;
    height: 1px;
    background: #626b78;
    content: '';
    transform: translateX(-50%);
  }

  .room-splitter::before {
    top: 11px;
  }

  .room-splitter::after {
    bottom: 11px;
  }

  .room-splitter-handle {
    width: 46px;
    height: 5px;
    border-radius: 3px;
    background: #9aa2ae;
  }

  .room-splitter:hover,
  .room-splitter:focus-visible,
  .employee-room.is-resizing .room-splitter {
    background: #252a32;
    color: #ffffff;
    outline: none;
  }

  .room-splitter:focus-visible .room-splitter-handle,
  .employee-room.is-resizing .room-splitter-handle {
    background: var(--orange, #ff5f12);
  }

  .room-chat-panel {
    grid-row: 4;
  }

  .room-chat-panel .chat-input-bar {
    position: static;
  }

  .live-workspace-head {
    min-height: 44px;
    padding: 6px 10px;
  }

  .live-workspace-kicker,
  #liveWorkspaceApplication,
  .live-workspace-mode {
    display: none;
  }

  .live-workspace-employee {
    font-size: 0.8125rem;
  }

  #liveWorkspaceObjective {
    font-size: 0.6875rem;
  }

  .live-workspace-state {
    max-width: 35%;
    font-size: 0.6875rem;
  }

  .live-workspace-frame {
    width: 100%;
    height: auto;
    min-height: 22px;
    flex: 1 1 auto;
    aspect-ratio: auto;
  }

  .live-workspace-controls {
    min-height: 48px;
    padding: 2px 8px;
    grid-template-columns: max-content repeat(5, 44px);
    justify-content: space-between;
  }

  .live-workspace-freshness {
    position: absolute;
    z-index: 3;
    left: 7px;
    bottom: 54px;
    max-width: calc(100% - 14px);
    padding: 3px 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    background: rgba(17, 19, 24, 0.84);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (min-width: 768px) and (max-width: 1023px) and (max-height: 500px) {
  .live-workspace-head {
    min-height: 50px;
    padding: 6px 10px;
  }

  .live-workspace-kicker,
  #liveWorkspaceApplication,
  .live-workspace-mode {
    display: none;
  }

  .live-workspace-frame {
    min-height: 0;
    flex: 1 1 auto;
    aspect-ratio: auto;
  }

  .live-workspace-controls {
    min-height: 52px;
    padding: 4px 8px;
    grid-template-columns: max-content repeat(5, 44px);
  }

  .live-workspace-freshness {
    display: none;
  }
}

@media (max-width: 360px) {
  .employee-room {
    height: calc(100dvh - 156px - env(safe-area-inset-bottom));
  }

  .room-tab {
    padding-inline: 6px;
  }

  .live-workspace-head {
    align-items: flex-start;
    gap: 10px;
  }

  .live-workspace-state {
    max-width: 40%;
    font-size: 0.6875rem;
  }

  .live-workspace-controls {
    min-height: 50px;
    padding-inline: 8px;
    grid-template-columns: repeat(6, 44px);
  }

  .live-workspace-controls button[data-open-support] {
    width: 44px;
    padding-inline: 0;
    font-size: 0.6875rem;
    white-space: normal;
  }

  .live-workspace-freshness {
    bottom: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .employee-room *,
  .employee-room *::before,
  .employee-room *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Narrow screens use tabs; desktop keeps the computer beside the conversation. */
body.portal-app #employeeRoom {
  display: flex;
  flex-direction: column;
  max-width: 1040px;
  margin-inline: auto;
  border-radius: 16px;
}
#employeeRoom .room-tabs {
  display: flex;
  flex: 0 0 auto;
  height: 48px;
  border-bottom: 1px solid var(--room-line);
  background: var(--room-graphite);
}
#employeeRoom .room-tab {
  flex: 1;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #acb0b6;
  font-size: 0.875rem;
  font-weight: 600;
}
#employeeRoom .room-tab[aria-selected='true'] {
  color: #fff6eb;
  border-bottom-color: #ff6a1a;
}
#employeeRoom .room-chat-panel,
#employeeRoom .room-live-panel { flex: 1; min-height: 0; }
#employeeRoom .room-chat-panel[hidden],
#employeeRoom .room-live-panel[hidden],
#employeeRoom .room-needs-panel[hidden],
#employeeRoom .room-splitter { display: none !important; }
#employeeRoom .room-needs-panel:not([hidden]) {
  position: static;
  width: 100%;
  max-width: none;
  flex: 1;
  overflow: auto;
}
#employeeRoom .chat-head { padding: 16px 20px; }
#employeeRoom .chat-input-bar { padding: 12px 16px; }
#employeeRoom .chat-input { font-size: 16px; min-height: 48px; }
#employeeRoom .chat-send { min-width: 48px; min-height: 48px; }
#employeeRoom .chat-bubble { max-width: 88%; line-height: 1.6; }
body.portal-app #employeeRoom .chat-work-link {
  border-color: #e9d9c6;
  border-left-color: #ff6a1a;
  background: #fff6eb;
}
#employeeRoom .chat-work-link > span:last-child { color: #92470e; }
#employeeRoom .chat-work-dot { background: #ff6a1a; }
@media (min-width: 768px) {
  body.portal-app #employeeRoom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.65fr);
    grid-template-rows: 48px minmax(0, 1fr);
    max-width: none;
  }
  #employeeRoom .room-tabs { grid-column: 1 / -1; grid-row: 1; }
  #employeeRoom .room-tab[hidden] { display: none; }
  #employeeRoom .room-live-panel { grid-column: 1; grid-row: 2; }
  #employeeRoom .room-chat-panel {
    grid-column: 2;
    grid-row: 2;
    border-left: 1px solid var(--room-line);
  }
  #employeeRoom .room-needs-panel:not([hidden]) { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 768px) {
  body.portal-app #employeeRoom {
    height: calc(100dvh - 132px - env(safe-area-inset-bottom));
    border-radius: 0;
  }
  #employeeRoom .chat-bubble { max-width: 94%; }
}

/* A finished task keeps its chip as a quiet "Done · View result". */
.room-chat-panel .chat-work-link.done .chat-work-dot,
#employeeRoom .chat-work-link.done .chat-work-dot { background: var(--ok, #7fd1a0); animation: none; }

/* The work sheet leads with its current state. */
body.portal-app .work-detail-status { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px;
  margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line, rgba(255,248,237,.12)); border-radius: 10px; }
body.portal-app .work-detail-status strong { color: var(--text, #fff8ed); font-size: 15px; }
body.portal-app .work-detail-status span:last-child { color: var(--text-2, #c3c8cf); font-size: 13px; }
body.portal-app .work-detail-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3, #8a9099); align-self: center; }
body.portal-app .work-detail-status.done .work-detail-status-dot { background: var(--ok, #7fd1a0); }
body.portal-app .work-detail-status.running .work-detail-status-dot { background: #ff9257; }
body.portal-app .work-detail-status.attention .work-detail-status-dot { background: var(--warn, #f0b34a); }
body.portal-app .work-detail-status.stuck .work-detail-status-dot { background: var(--stop, #ff6b5e); }
body.portal-app .work-detail-status.closed .work-detail-status-dot { background: var(--text-3, #8a9099); }
@media (prefers-reduced-motion: no-preference) {
  body.portal-app .work-detail-status.running .work-detail-status-dot { animation: work-status-pulse 1.6s ease-in-out infinite; }
}
@keyframes work-status-pulse { 50% { opacity: .35; } }
