/* Global PowerAI operating-system shell. App-local navigation stays with each app. */

:root {
  --bg: #f2f3ef;
  --surface: #fbfcf9;
  --surface-muted: #e9ece6;
  --border: #d9ddd6;
  --text: #1c221e;
  --muted: #6c766e;
  --accent: #32635c;
  --accent-strong: #244d47;
  --brand: #d9f56f;
  --shadow: 0 18px 52px rgba(21, 29, 24, .12);
}

body {
  background: var(--bg);
  letter-spacing: -.008em;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.shell > .main {
  grid-column: 1;
  grid-row: 2;
  height: calc(100vh - 56px);
  min-height: 0;
}

.shell-icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Global top bar */

.topbar {
  position: relative;
  z-index: 100;
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 620px) minmax(310px, 1fr);
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 0 12px 0 8px;
  border-bottom: 1px solid #d9ddd7;
  background: rgba(250, 251, 248, .94);
  box-shadow: 0 1px 8px rgba(22, 29, 24, .045);
  backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-alert-slot { position: relative; display: grid; }
.powerai-alert-button { position: relative; }
.powerai-alert-button > span { position: absolute; top: -3px; right: -4px; display: grid; place-items: center; min-width: 15px; height: 15px; padding: 0 4px; border: 2px solid #f7f7f4; border-radius: 999px; background: #b75b50; color: #fff; font-size: 7px; font-weight: 800; line-height: 1; }
.powerai-alert-center { position: absolute; z-index: 80; top: calc(100% + 11px); right: -55px; width: min(390px, calc(100vw - 24px)); overflow: hidden; border: 1px solid #d8ddd7; border-radius: 15px; background: rgba(252, 252, 249, .98); box-shadow: 0 22px 60px rgba(38, 46, 40, .2); backdrop-filter: blur(16px); }
.powerai-alert-center > header { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 17px 18px 13px; border-bottom: 1px solid #e5e8e3; }
.powerai-alert-center > header span { display: block; color: #7d877f; font-size: 7px; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; }
.powerai-alert-center > header h2 { margin: 3px 0 0; color: #2d3931; font-size: 15px; }
.powerai-alert-center > header button,
.powerai-alert-center > footer button { border: 0; background: none; color: #557563; font-size: 8.5px; font-weight: 700; cursor: pointer; }
.powerai-alert-list { max-height: min(480px, calc(100vh - 175px)); overflow: auto; }
.powerai-alert { position: relative; display: grid; grid-template-columns: 5px minmax(0, 1fr) 26px; gap: 8px; align-items: start; padding: 12px 10px 12px 12px; border-bottom: 1px solid #e8ebe7; background: #fff; }
.powerai-alert.unread { background: #f5f9f5; }
.powerai-alert-indicator { width: 5px; height: 5px; margin-top: 5px; border-radius: 50%; background: transparent; }
.powerai-alert.unread .powerai-alert-indicator { background: #5a8c70; box-shadow: 0 0 0 3px #e2efe6; }
.powerai-alert.critical.unread .powerai-alert-indicator { background: #b75b50; box-shadow: 0 0 0 3px #f4e4e1; }
.powerai-alert > button[data-alert-open] { min-width: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.powerai-alert small { display: block; margin-bottom: 4px; color: #89928c; font-size: 7.5px; font-weight: 690; text-transform: uppercase; }
.powerai-alert strong { display: block; overflow: hidden; margin-bottom: 3px; color: #344139; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.powerai-alert button > span { display: -webkit-box; overflow: hidden; color: #727d76; font-size: 8.5px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.powerai-alert-dismiss { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #9aa19c; cursor: pointer; }
.powerai-alert-dismiss:hover { background: #edf0ec; color: #536159; }
.powerai-alert-dismiss .shell-icon { width: 12px; height: 12px; }
.powerai-alert-empty { display: grid; justify-items: center; gap: 6px; padding: 34px 20px; color: #879089; text-align: center; }
.powerai-alert-empty .shell-icon { width: 25px; height: 25px; color: #6c8d79; }
.powerai-alert-empty strong { color: #536058; font-size: 10px; }
.powerai-alert-empty span { font-size: 8.5px; }
.powerai-alert-center > footer { display: flex; justify-content: flex-end; padding: 10px 13px; background: #f7f8f5; }
.powerai-alert-center > footer button { display: inline-flex; align-items: center; gap: 5px; }
.powerai-alert-center > footer .shell-icon { width: 12px; height: 12px; }

.topbar-left { gap: 5px; }
.topbar-right { justify-content: flex-end; gap: 5px; }

.topbar-icon-button,
.topbar-brand,
.topbar-avatar {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.topbar-icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border-radius: 10px;
  color: #5f6a62;
  transition: color .15s ease, background .15s ease;
}

.topbar-icon-button:hover,
.topbar-icon-button.active {
  background: #e8ebe6;
  color: #1f2822;
}

.app-launcher-button.active {
  background: #1a211c;
  color: #f8faf7;
}

.topbar-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 8px 3px 5px;
  border-radius: 10px;
}

.topbar-brand:hover { background: #eef0ec; }

.topbar-mark {
  position: relative;
  width: 31px;
  height: 31px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: var(--brand);
  color: #172017;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: -.07em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}

.topbar-mark::after,
.chat-welcome-mark::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #111512;
}

.topbar-brand strong {
  overflow: hidden;
  color: #202722;
  font-size: 14px;
  font-weight: 730;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  margin: 0 7px;
  background: #daddd7;
}

.topbar-current-app {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #4c5750;
}

.topbar-current-app .shell-icon {
  width: 17px;
  height: 17px;
}

.topbar-current-app strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-command {
  height: 38px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 0 9px 0 12px;
  border: 1px solid #d7dbd4;
  border-radius: 12px;
  background: #f3f4f0;
  color: #778079;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.topbar-command:focus-within {
  border-color: #9ca89d;
  background: #fff;
  box-shadow: 0 5px 20px rgba(23, 31, 26, .08);
}

.topbar-command .shell-icon {
  width: 18px;
  height: 18px;
}

.topbar-command input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.topbar-command input::placeholder { color: #879088; }

.topbar-command-hint {
  padding: 3px 6px;
  border: 1px solid #d7dbd4;
  border-radius: 6px;
  color: #8a938b;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.topbar-workspace {
  height: 38px;
  display: grid;
  grid-template-columns: auto minmax(72px, auto) 16px;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 230px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #68726a;
  transition: background .15s ease, border-color .15s ease;
}

.topbar-workspace:hover,
.topbar-workspace:focus-within {
  border-color: #dfe2dc;
  background: #f0f2ed;
}

.topbar-workspace-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar-workspace select {
  width: 100%;
  min-width: 0;
  appearance: none;
  overflow: hidden;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #28312b;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  cursor: pointer;
}

.topbar-workspace .shell-icon {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 1px solid #ccd2cb;
  border-radius: 50%;
  background: #edf0eb;
  color: #273029;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .02em;
}

.topbar-avatar:hover {
  border-color: #8f9b91;
  background: #fff;
}

.topbar-avatar.active { border-color: #718076; background: #fff; box-shadow: 0 0 0 3px rgba(74, 105, 86, .1); }

/* Signed-in account switcher */

.account-switcher { position: relative; display: grid; }
.account-switcher-scrim { position: fixed; z-index: 70; inset: 56px 0 0; padding: 0; border: 0; background: rgba(22, 28, 24, .08); backdrop-filter: blur(2px); cursor: default; }
.account-switcher-menu { position: absolute; z-index: 80; top: calc(100% + 11px); right: 0; width: min(370px, calc(100vw - 20px)); overflow: hidden; border: 1px solid #d8ddd7; border-radius: 16px; background: rgba(252, 253, 250, .99); box-shadow: 0 24px 70px rgba(20, 28, 23, .22); color: #28322b; backdrop-filter: blur(18px); }
.account-switcher-menu > header { display: grid; gap: 2px; padding: 18px 18px 14px; border-bottom: 1px solid #e4e8e2; }
.account-switcher-menu > header > span { color: #7d877f; font-size: 9px; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; }
.account-switcher-menu > header strong { margin-top: 3px; font-size: 14px; }
.account-switcher-menu > header small { overflow: hidden; color: #737e76; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.account-switcher-list { max-height: min(330px, calc(100vh - 270px)); overflow-y: auto; padding: 7px; }
.account-switcher-frame { display: block; width: 100%; height: 52px; min-height: 52px; max-height: min(250px, calc(100vh - 300px)); border: 0; background: transparent; }
.account-switcher-account { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px; border: 0; border-radius: 10px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.account-switcher-account:hover { background: #eef1ec; }
.account-switcher-account.current { background: #f4f6f2; cursor: default; }
.account-switcher-account:disabled { color: inherit; opacity: 1; }
.account-switcher-account-avatar { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #cdd4cd; border-radius: 50%; background: #e8ede7; font-size: 9px; font-weight: 780; }
.account-switcher-account-copy { min-width: 0; display: grid; gap: 2px; }
.account-switcher-account-copy strong,
.account-switcher-account-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-switcher-account-copy strong { font-size: 12px; }
.account-switcher-account-copy small { color: #7a847d; font-size: 9.5px; }
.account-switcher-account > .shell-icon { width: 15px; height: 15px; color: #829087; }
.account-switcher-current { color: #567362; font-size: 8px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.account-switcher-status,
.account-switcher-error { margin: 0; padding: 18px 12px; color: #78827a; font-size: 11px; text-align: center; }
.account-switcher-error { color: #a35049; }
.account-switcher-actions { display: grid; padding: 7px; border-top: 1px solid #e4e8e2; background: #f7f8f5; }
.account-switcher-actions button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: #455249; font-size: 11px; font-weight: 650; text-align: left; cursor: pointer; }
.account-switcher-actions button:hover { background: #e9ede7; }
.account-switcher-actions button.danger { color: #9f4c47; }
.account-switcher-actions button.danger:hover { background: #f3e8e7; }
.account-switcher-actions .shell-icon { width: 16px; height: 16px; }

/* App launcher */

.topbar-scrim {
  position: fixed;
  z-index: 0;
  inset: 56px 0 0;
  background: rgba(22, 28, 24, .08);
  backdrop-filter: blur(2px);
}

.app-launcher {
  position: absolute;
  z-index: 2;
  top: 49px;
  left: 8px;
  width: min(530px, calc(100vw - 16px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid #d9ded7;
  border-radius: 16px;
  background: rgba(252, 253, 250, .98);
  box-shadow: 0 24px 70px rgba(20, 28, 23, .2);
  color: var(--text);
}

.app-launcher header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.app-launcher header span,
.app-launcher-section-label {
  color: #778178;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.app-launcher h2 {
  margin: 3px 0 0;
  font-size: 23px;
  font-weight: 690;
  letter-spacing: -.04em;
}

.app-launcher-section-label {
  margin: 0 3px 8px;
}

.app-launcher-grid,
.app-launcher-system {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 19px;
}

.app-launcher-system { margin-bottom: 0; }

.app-launcher-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, transform .14s ease;
}

.app-launcher-item:hover {
  transform: translateY(-1px);
  border-color: #dce1da;
  background: #f3f5f0;
}

.app-launcher-item.active {
  border-color: #d5ddc0;
  background: #f2f7df;
}

.app-launcher-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e9ede7;
  color: #354139;
}

.app-launcher-icon.chat { background: #dff39b; color: #2b3c22; }
.app-launcher-icon.concord { background: #dfe9fa; color: #31517d; }
.app-launcher-icon.drive { background: #f8e4c2; color: #79552c; }
.app-launcher-icon.changes { background: #eadff4; color: #67437c; }
.app-launcher-icon.floweave { background: #d9ece8; color: #2f6159; }
.app-launcher-icon.memory { background: #ebe8dd; color: #5b5748; }
.app-launcher-icon.settings { background: #e7e9e7; color: #525b54; }

.app-launcher-icon .shell-icon { width: 21px; height: 21px; }

.app-launcher-item > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-launcher-item strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-launcher-item small {
  overflow: hidden;
  color: #7b857d;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat-local navigation */

.chat-main {
  position: relative;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  overflow: hidden;
  background: #f2f3ef;
  transition: grid-template-columns .18s ease;
}

.chat-main:not(.history-open) {
  grid-template-columns: 0 minmax(0, 1fr);
}

.chat-history-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #dce0da;
  background: #f7f8f5;
  opacity: 1;
  transition: opacity .12s ease;
}

.chat-main:not(.history-open) .chat-history-panel {
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.chat-workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-history-open {
  position: absolute;
  z-index: 4;
  top: 13px;
  left: 13px;
  width: 36px;
  height: 36px;
  display: grid;
  padding: 0;
  place-items: center;
  border: 1px solid #d8ddd6;
  border-radius: 10px;
  background: rgba(251, 252, 249, .92);
  color: #536057;
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(24, 31, 26, .08);
}

.chat-main.history-open .chat-history-open { display: none; }

.chat-history-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 15px 13px 10px 17px;
}

.chat-history-header > div { display: grid; gap: 2px; }
.chat-history-header span,
.chat-history-label {
  color: #858e86;
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .105em;
  text-transform: uppercase;
}

.chat-history-header strong {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -.02em;
}

.chat-history-icon-button {
  width: 31px;
  height: 31px;
  display: grid;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #768078;
  cursor: pointer;
}

.chat-history-icon-button:hover { background: #e8ebe6; color: #263029; }
.chat-history-icon-button .shell-icon { width: 17px; height: 17px; }

.chat-new-button {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 1px 12px 11px;
  padding: 8px 12px;
  border: 0;
  border-radius: 11px;
  background: #1e2822;
  color: #f7faf7;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.chat-new-button:hover { background: #2b3830; }
.chat-new-button .shell-icon { width: 16px; height: 16px; }

.chat-history-filter {
  min-height: 36px;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  margin: 0 12px 15px;
  padding: 0 10px;
  border: 1px solid #dde1db;
  border-radius: 10px;
  background: #fff;
  color: #8a938b;
}

.chat-history-filter:focus-within { border-color: #aab4ab; }
.chat-history-filter .shell-icon { width: 15px; height: 15px; }
.chat-history-filter input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
}

.chat-history-label { margin: 0 18px 6px; }

.chat-history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 14px;
  scrollbar-width: thin;
  scrollbar-color: #c7cdc6 transparent;
}

.chat-history-session {
  min-width: 0;
  min-height: 34px;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  color: #68726b;
  font-size: 11px;
  text-decoration: none;
}

.chat-history-session .shell-icon { width: 14px; height: 14px; color: #929b94; }
.chat-history-session:hover { background: #ecefea; color: #28312b; }
.chat-history-session.active { background: #e4e8e2; color: #1f2822; font-weight: 650; }
.chat-history-session .session-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-empty { padding: 9px 10px; color: #949c95; font-size: 11px; }

.topbar button:focus-visible,
.topbar input:focus-visible,
.topbar select:focus-visible,
.chat-history-panel button:focus-visible,
.chat-history-panel input:focus-visible,
.chat-history-panel a:focus-visible,
.chat-history-open:focus-visible {
  outline: 2px solid #75906f;
  outline-offset: 2px;
}

@media (max-width: 1280px) {
  .topbar-workspace-label { display: none; }
  .topbar-workspace { grid-template-columns: minmax(72px, 150px) 16px; }
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: minmax(210px, auto) minmax(220px, 1fr) minmax(240px, auto);
    gap: 9px;
  }

  .topbar-brand strong { display: none; }
  .topbar-workspace { grid-template-columns: minmax(72px, 130px) 16px; }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: auto minmax(100px, 1fr) auto;
    gap: 6px;
    padding-right: 7px;
  }

  .topbar-divider,
  .topbar-current-app,
  .topbar-command-hint,
  #settingsQuickBtn {
    display: none;
  }

  .topbar-brand { padding-right: 3px; }
  .topbar-workspace { max-width: 110px; padding: 0 5px; }
  .topbar-workspace select { font-size: 11px; }

  .app-launcher {
    padding: 15px;
    border-radius: 14px;
  }

  .chat-main,
  .chat-main:not(.history-open) {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat-history-panel {
    position: absolute;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(286px, calc(100vw - 46px));
    border-right-color: #dce0da;
    box-shadow: 18px 0 50px rgba(20, 28, 23, .18);
    transform: translateX(-105%);
    opacity: 1;
    pointer-events: auto;
    transition: transform .18s ease;
  }

  .chat-main.history-open .chat-history-panel { transform: translateX(0); }
  .chat-main:not(.history-open) .chat-history-panel { opacity: 1; }
}

@media (max-width: 520px) {
  .topbar-command { display: none; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar-right { grid-column: 2; }
  .app-launcher-grid,
  .app-launcher-system { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .topbar *,
  .chat-main,
  .chat-history-panel {
    transition-duration: .01ms !important;
  }
}
