/* The interactive preview, laid out like the Opaya app: an icons-only sidebar, the agent's own sidebar that follows
   the open view (chats, terminal windows or Manage sections), and Chat / Terminal / Manage in the top bar. */
.app-layout {
  grid-template-columns: 52px 206px minmax(0, 1fr);
  min-height: 548px;
}
.app-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 0;
  background: #f3f6f2;
  border-right: 1px solid var(--line);
}
.rail-logo,
.rail-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #6f786d;
}
.rail-logo {
  background: #fff;
  border: 1px solid #dce3d9;
}
.rail-logo img {
  width: 16px;
  height: 16px;
}
.rail-icon svg {
  width: 14px;
  height: 14px;
}
.rail-cap {
  margin-top: 6px;
  font: 6.5px var(--mono);
  letter-spacing: 0.06em;
  color: #9aa294;
}
.rail-agents {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.rail-agent {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  padding: 0;
}
.rail-agent .agent-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.rail-agent:hover {
  background: #e9eee7;
}
.rail-agent.active {
  background: #e3ebe2;
  box-shadow: inset 0 0 0 1px #b9cdb9;
}
.rail-agent.active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 11px;
  bottom: 11px;
  width: 2px;
  border-radius: 2px;
  background: var(--green);
}
.rail-agent > .status-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  box-shadow: 0 0 0 2px #f3f6f2;
}
.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.agent-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f8faf7;
  border-right: 1px solid var(--line);
}
.side-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 12px 12px;
}
.side-head > div {
  min-width: 0;
  flex: 1;
}
.side-head strong {
  display: block;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-head small {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 8.5px;
  color: #8c948b;
  margin-top: 2px;
}
.side-head .status-dot {
  width: 5px;
  height: 5px;
}
.side-power {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--green);
  border: 1px solid #b9d4c1;
  box-shadow: 0 0 0 3px #277b5812;
}
.side-power svg {
  width: 11px;
  height: 11px;
}
.side-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 2px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 7px;
  font: 7.5px var(--mono);
  letter-spacing: 0.05em;
  color: #8b938b;
}
.side-label svg {
  width: 11px;
  height: 11px;
}
.side-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px 6px;
  padding: 0 8px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #e0e5de;
  background: #fff;
  font-size: 9px;
  color: #9aa294;
}
.side-search svg {
  width: 10px;
  height: 10px;
}
.side-day {
  padding: 7px 6px 3px;
  font: 6.5px var(--mono);
  letter-spacing: 0.05em;
  color: #a0a79c;
}
.side-chat,
.side-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 25px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 9.5px;
  color: #5d665b;
}
.side-chat > span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-chat small {
  font-size: 8px;
  color: #a0a79c;
}
.side-chat.active,
.side-item.active {
  background: #e3ebe2;
  color: #24382a;
}
.side-chat.hidden > span {
  font-style: italic;
  color: #8c948b;
}
.side-chat.ended > span {
  text-decoration: line-through;
  color: #9aa294;
}
.side-item svg {
  width: 12px;
  height: 12px;
  color: #8c948b;
}
.side-item.active svg {
  color: var(--green);
}
.side-item.danger,
.side-item.danger svg {
  color: #b5655b;
}
.side-foot {
  border-top: 1px solid var(--line);
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.side-foot:empty {
  display: none;
}
/* Top bar: the agent, then its views. */
.app-toolbar {
  height: 50px;
  padding: 0 16px 0 14px;
}
.breadcrumb {
  gap: 8px;
  overflow: hidden;
}
.breadcrumb strong {
  font-weight: 600;
}
.toolbar-machine {
  color: var(--green) !important;
  white-space: nowrap;
}
.app-tabs {
  height: 30px;
  gap: 2px;
  padding: 2px;
  border: 1px solid #e0e5de;
  border-radius: 8px;
  background: #f6f8f5;
  margin-left: auto;
}
.app-tabs button {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  font-size: 9.5px;
}
.app-tabs button.active {
  background: #fff;
  color: #24382a;
  box-shadow: 0 0 0 1px #c9dccd;
}
.app-tabs svg {
  width: 11px;
  height: 11px;
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 7px 0 9px;
  border-radius: 7px;
  border: 1px solid #e0e5de;
  font-size: 9px;
  color: #9aa294;
  white-space: nowrap;
}
.toolbar-search svg {
  width: 10px;
  height: 10px;
}
.toolbar-search kbd {
  font: 7px var(--mono);
  border: 1px solid #e0e5de;
  border-radius: 4px;
  padding: 1px 4px;
  margin-left: 18px;
}
.terminal-panel,
.manage-panel {
  flex: 1;
  height: auto;
  min-height: 301px;
}
/* Manage: who it is, what it is connected to, and its main actions. */
.manage-panel {
  padding: 18px 20px;
  overflow: auto;
}
.manage-hero {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 188px;
  border-radius: 12px;
  border: 1px solid #dfe7dd;
  background: radial-gradient(120% 140% at 75% 40%, #e4f3e9 0%, #f3f8f4 55%, #fafcfa 100%);
  overflow: hidden;
}
.manage-card {
  position: relative;
  z-index: 1;
  margin: 14px;
  padding: 16px;
  width: min(300px, 55%);
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e0e7df;
  box-shadow: 0 8px 20px -14px #1d3a2a40;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.manage-id {
  display: flex;
  align-items: center;
  gap: 10px;
}
.manage-id .agent-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.manage-id strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.manage-id small {
  font-size: 9px;
  color: #8c948b;
}
.manage-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 8px;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid #e0e5de;
  color: #5d665b;
}
.fact.ok {
  border-color: #b9d4c1;
  color: var(--green);
}
.fact .status-dot {
  width: 4px;
  height: 4px;
}
.manage-actions {
  display: flex;
  gap: 5px;
  margin-top: auto;
}
.manage-actions span {
  font-size: 8.5px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid #dfe5dd;
  background: #fbfcfb;
}
.manage-orbit {
  position: relative;
  flex: 1;
  min-width: 140px;
}
.orbit-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150px;
  height: 52px;
  margin: -26px 0 0 -75px;
  border: 1px solid #9fcfb2;
  border-radius: 50%;
  transform: rotate(-8deg);
  opacity: 0.8;
}
.orbit-ring.outer {
  width: 196px;
  height: 70px;
  margin: -35px 0 0 -98px;
  transform: rotate(10deg);
  opacity: 0.45;
}
.orbit-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 14px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #7fd7a5, #2f8f61);
  box-shadow: 0 0 40px #3fae7866;
  animation: orbit-breathe 4s ease-in-out infinite;
}
.orbit-node {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #cfe2d5;
  color: var(--green);
}
.orbit-node svg {
  width: 11px;
  height: 11px;
}
.orbit-node.n1 { left: calc(50% + 76px); top: calc(50% - 8px); }
.orbit-node.n2 { left: calc(50% - 72px); top: calc(50% - 16px); color: #b78a2b; }
.orbit-node.n3 { left: calc(50% - 44px); top: calc(50% + 22px); color: #c6703b; }
.orbit-node.n4 { left: calc(50% + 50px); top: calc(50% + 24px); }
.orbit-node.n5 { left: calc(50% + 10px); top: calc(50% - 34px); color: #3f7fc0; }
@keyframes orbit-breathe {
  50% { transform: rotate(45deg) scale(1.06); box-shadow: 0 0 52px #3fae7880; }
}
.manage-quick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.manage-quick span {
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 9px;
  border-radius: 9px;
  border: 1px solid #e3e8e1;
  background: #fbfcfb;
}
.manage-quick svg {
  grid-row: span 2;
  width: 13px;
  height: 13px;
  color: var(--green);
}
.manage-quick strong {
  font-size: 9px;
  font-weight: 600;
}
.manage-quick small {
  font-size: 7.5px;
  color: #8c948b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Composer chips, as under the app's message box. */
.composer-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.chip,
.chip-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid #e0e5de;
  font-size: 8.5px;
  white-space: nowrap;
}
.chip-icon {
  padding: 0 5px;
}
.chip svg,
.chip-icon svg {
  width: 10px !important;
  height: 10px !important;
}
.app-statusbar {
  gap: 10px;
}
.status-pill {
  font-size: 7.5px;
  padding: 1px 8px;
  border-radius: 20px;
  border: 1px solid #ecd9a8;
  background: #fbf3dc;
  color: #8a6513;
}
@media (prefers-reduced-motion: reduce) {
  .orbit-core { animation: none; }
}
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 50px 180px minmax(0, 1fr);
  }
  .toolbar-search kbd {
    display: none;
  }
}
@media (max-width: 800px) {
  .app-layout {
    grid-template-columns: 46px 156px minmax(0, 1fr);
  }
  .toolbar-search,
  .toolbar-machine,
  .breadcrumb > svg {
    display: none;
  }
  .manage-quick {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-pill {
    display: none;
  }
}
@media (max-width: 580px) {
  .app-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    min-height: 0;
  }
  .app-statusbar > span:last-child {
    display: none;
  }
  .status-pill {
    font-size: 6.5px;
    white-space: nowrap;
  }
  #status-left {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .app-rail {
    flex-direction: row;
    padding: 6px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .rail-agents {
    flex-direction: row;
  }
  .rail-cap,
  .rail-bottom,
  .rail-icon:not(.rail-bottom .rail-icon) {
    display: none;
  }
  .rail-agent.active::before {
    left: 11px;
    right: 11px;
    top: auto;
    bottom: -3px;
    width: auto;
    height: 2px;
  }
  .agent-side {
    display: none;
  }
  .app-toolbar {
    height: 42px;
    padding-inline: 10px;
  }
  .app-tabs button {
    padding: 0 7px;
    font-size: 8.5px;
  }
  .manage-panel {
    padding: 12px;
  }
  .manage-card {
    width: auto;
    flex: 1;
  }
  .manage-orbit {
    display: none;
  }
  .composer-chips .chip:nth-child(2) {
    display: none;
  }
}
/* Dark theme */
[data-theme="dark"] .app-rail {
  background: #161816;
}
[data-theme="dark"] .agent-side {
  background: var(--surface);
}
[data-theme="dark"] .rail-logo,
[data-theme="dark"] .side-search,
[data-theme="dark"] .manage-card,
[data-theme="dark"] .manage-quick span,
[data-theme="dark"] .manage-actions span,
[data-theme="dark"] .orbit-node {
  background: var(--surface-raised);
  border-color: #3a423b;
}
[data-theme="dark"] .rail-agent:hover {
  background: var(--surface-raised);
}
[data-theme="dark"] .rail-agent.active,
[data-theme="dark"] .side-chat.active,
[data-theme="dark"] .side-item.active {
  background: #29392d;
  color: #d9eadf;
  box-shadow: none;
}
[data-theme="dark"] .rail-agent > .status-dot {
  box-shadow: 0 0 0 2px #161816;
}
[data-theme="dark"] .side-head strong,
[data-theme="dark"] .manage-id strong {
  color: var(--page-text);
}
[data-theme="dark"] .side-chat,
[data-theme="dark"] .side-item,
[data-theme="dark"] .fact,
[data-theme="dark"] .chip,
[data-theme="dark"] .chip-icon {
  color: var(--text-secondary);
  border-color: #3a423b;
}
[data-theme="dark"] .rail-icon,
[data-theme="dark"] .rail-cap,
[data-theme="dark"] .side-label,
[data-theme="dark"] .side-day,
[data-theme="dark"] .side-head small,
[data-theme="dark"] .side-chat small,
[data-theme="dark"] .manage-id small,
[data-theme="dark"] .manage-quick small,
[data-theme="dark"] .toolbar-search {
  color: var(--text-muted);
}
[data-theme="dark"] .app-tabs,
[data-theme="dark"] .toolbar-search,
[data-theme="dark"] .toolbar-search kbd {
  background: #1d201d;
  border-color: #363d37;
}
[data-theme="dark"] .app-tabs button.active {
  background: #29392d;
  color: #d9eadf;
  box-shadow: 0 0 0 1px #3d5a47;
}
[data-theme="dark"] .side-power,
[data-theme="dark"] .fact.ok {
  border-color: #3d5a47;
  color: #8fd1a9;
}
[data-theme="dark"] .toolbar-machine {
  color: #8fd1a9 !important;
}
[data-theme="dark"] .manage-hero {
  border-color: #2f3a32;
  background: radial-gradient(120% 140% at 75% 40%, #183424 0%, #141a16 55%, #111411 100%);
}
[data-theme="dark"] .orbit-ring {
  border-color: #3f8a61;
}
[data-theme="dark"] .status-pill {
  background: #3a2f12;
  border-color: #6a5420;
  color: #f3cf7a;
}
