.ai-copilot {
  --ai-copilot-bg: rgba(255, 255, 255, 0.98);
  --ai-copilot-border: rgba(31, 41, 55, 0.16);
  --ai-copilot-shadow: 0 22px 48px rgba(15, 23, 42, 0.2);
  --ai-copilot-text: #172033;
  --ai-copilot-muted: #5a6578;
  --ai-copilot-accent: #0f6bff;
  --ai-copilot-accent-strong: #0a55ca;
  --ai-copilot-surface: #f5f7fb;
  --ai-copilot-success: #0f8a5f;
  --ai-copilot-warn: #b45309;
  --ai-copilot-danger: #b42318;
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 10000;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  background: var(--ai-copilot-bg);
  border: 1px solid var(--ai-copilot-border);
  border-radius: 14px;
  box-shadow: var(--ai-copilot-shadow);
  color: var(--ai-copilot-text);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: auto;
  backdrop-filter: blur(18px);
  font: 13px/1.45 "Segoe UI", Arial, sans-serif;
}

.ai-copilot.is-fullscreen {
  inset: 0;
  width: auto;
  max-height: none;
  height: 100dvh;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  grid-template-rows: auto auto auto minmax(120px, 1fr) auto auto;
}

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

.ai-copilot-launcher {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  min-width: 48px;
  height: 48px;
  border: 1px solid rgba(31, 41, 55, 0.18);
  border-radius: 999px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  font: 700 13px/1 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  touch-action: auto;
}

.ai-copilot-launcher[hidden] {
  display: none;
}

.ai-copilot__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ai-copilot-border);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 255, 0.18), transparent 48%),
    linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
}

.ai-copilot__bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-copilot__icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(31, 41, 55, 0.14);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ai-copilot-muted);
  font: 700 16px/1 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}

.ai-copilot__title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ai-copilot__meta {
  margin-top: 2px;
  color: var(--ai-copilot-muted);
  font-size: 12px;
}

.ai-copilot__status {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ai-copilot-border);
  background: #fbfcff;
  color: var(--ai-copilot-muted);
}

.ai-copilot__status strong {
  color: var(--ai-copilot-text);
}

.ai-copilot__status.is-success strong {
  color: var(--ai-copilot-success);
}

.ai-copilot__status.is-warning strong {
  color: var(--ai-copilot-warn);
}

.ai-copilot__status.is-error strong {
  color: var(--ai-copilot-danger);
}

.ai-copilot__current {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ai-copilot-border);
  background: var(--ai-copilot-surface);
}

.ai-copilot__current-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-copilot__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 107, 255, 0.09);
  color: var(--ai-copilot-accent-strong);
  font-weight: 600;
}

.ai-copilot__badge.is-empty {
  background: rgba(90, 101, 120, 0.1);
  color: var(--ai-copilot-muted);
}

.ai-copilot__homes {
  min-height: 96px;
  max-height: 220px;
  padding: 10px 14px 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-copilot__homes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-copilot__homes-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ai-copilot-muted);
}

.ai-copilot__home-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-copilot__home-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(15, 107, 255, 0.12);
  border-radius: 10px;
  background: #ffffff;
}

.ai-copilot__home-item.is-current {
  border-color: rgba(15, 107, 255, 0.35);
  background: rgba(15, 107, 255, 0.05);
}

.ai-copilot__home-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-copilot__home-name {
  font-weight: 600;
  word-break: break-word;
}

.ai-copilot__home-meta {
  color: var(--ai-copilot-muted);
  font-size: 12px;
}

.ai-copilot__response {
  min-height: 88px;
  max-height: 180px;
  padding: 12px 14px;
  border-top: 1px solid var(--ai-copilot-border);
  border-bottom: 1px solid var(--ai-copilot-border);
  background: #fff;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
}

.ai-copilot__composer {
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), #f8fbff);
}

.ai-copilot__composer textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid rgba(31, 41, 55, 0.14);
  border-radius: 10px;
  padding: 10px 12px;
  box-sizing: border-box;
  font: inherit;
  color: var(--ai-copilot-text);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.ai-copilot__composer textarea:focus {
  outline: 2px solid rgba(15, 107, 255, 0.18);
  border-color: rgba(15, 107, 255, 0.36);
}

.ai-copilot__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-copilot__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(31, 41, 55, 0.15);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ai-copilot-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ai-copilot__button:hover {
  border-color: rgba(15, 107, 255, 0.34);
}

.ai-copilot__button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.ai-copilot__button--primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--ai-copilot-accent), var(--ai-copilot-accent-strong));
  color: #fff;
}

.ai-copilot__button--ghost {
  background: rgba(15, 107, 255, 0.05);
  color: var(--ai-copilot-accent-strong);
}

@media (max-width: 900px) {
  .ai-copilot:not(.is-fullscreen) {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    max-height: calc(100dvh - 20px);
  }
}
