:root {
  --agent-sidebar-width: 360px;
}

body.agent-sidebar-open {
  --agent-sidebar-width: 360px;
}

body.agent-sidebar-open .wrap {
  margin-right: var(--agent-sidebar-width);
  transition: margin-right 0.2s ease;
}

body:not(.agent-sidebar-open) .wrap {
  margin-right: auto;
}

html.miot-shell-child body .wrap {
  margin-left: auto !important;
  margin-right: auto !important;
}

.agent-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2000;
  width: var(--agent-sidebar-width);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #111827;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.agent-sidebar.is-open {
  transform: translateX(0);
}

.agent-sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 16px;
  overflow: hidden;
}

.agent-palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.agent-palette-head h2 {
  margin: 0;
  font-size: 18px;
}

.agent-palette-close {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.agent-palette-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: auto;
  gap: 12px;
}

.agent-palette-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-log-entry {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.agent-log-user {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.22);
  margin-left: 12px;
}

.agent-log-agent {
  background: #0f1b33;
  border-color: rgba(255, 255, 255, 0.1);
  margin-right: 12px;
}

.agent-log-entry.is-error {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
}

.agent-log-entry.is-pending .agent-log-text {
  color: #94a3b8;
  font-style: italic;
}

.agent-log-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

.agent-log-user .agent-log-label {
  color: #7dd3fc;
}

.agent-log-text {
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-log-entry.is-error .agent-log-text {
  color: #fca5a5;
}

.agent-palette-footer {
  flex-shrink: 0;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.agent-palette-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.agent-palette-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0b1730;
  color: #f8fafc;
  font: inherit;
}

.agent-palette-voice-btn,
.agent-palette-submit-btn {
  min-height: 42px;
}

.agent-palette-voice-btn {
  width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.agent-palette-voice-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.agent-palette-voice-btn.is-listening {
  border-color: rgba(56, 189, 248, 0.75);
  color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

.agent-palette-results {
  display: grid;
  gap: 8px;
}

.agent-palette-result {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1b33;
  color: #f8fafc;
  cursor: pointer;
  font: inherit;
}

.agent-palette-result:hover {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.08);
}

.agent-palette-result-title {
  font-weight: 700;
}

.agent-palette-result-sub {
  color: #cbd5e1;
  font-size: 13px;
}

@media (max-width: 900px) {
  body.agent-sidebar-open .wrap {
    margin-right: 0;
  }

  .agent-sidebar {
    width: min(100vw, 420px);
  }
}

@media (max-width: 700px) {
  .agent-palette-input-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "input input"
      "voice submit";
  }

  .agent-palette-input {
    grid-area: input;
  }

  .agent-palette-voice-btn {
    grid-area: voice;
  }

  .agent-palette-submit-btn {
    grid-area: submit;
  }
}
