/* Concierge chat widget */
#concierge {
  position: fixed;
  right: 22px;
  /* Clear the iOS home indicator / Safari toolbar */
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  font-family: var(--font);
}

.cg-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.cg-bubble:hover { transform: scale(1.07); }

/* The display:flex below would override the [hidden] attribute — never let it. */
.cg-panel[hidden] { display: none !important; }

.cg-panel {
  width: min(340px, calc(100vw - 44px));
  height: min(440px, 70dvh);
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cg-header {
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cg-close {
  border: none;
  background: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.cg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cg-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cg-assistant {
  align-self: flex-start;
  background: #f1f3f5;
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.cg-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}
.cg-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}
.cg-input:focus { border-color: var(--accent); }
.cg-send {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Mobile: full-screen chat ---------- */
@media (max-width: 680px) {
  body.cg-open { overflow: hidden; }
  /* When the panel is open, take over the whole screen like a chat app */
  #concierge:has(.cg-panel:not([hidden])) {
    inset: 0;
    right: 0;
    bottom: 0;
  }
  .cg-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh; /* tracks Safari's collapsing toolbar */
    border-radius: 0;
  }
  .cg-header {
    padding: 16px;
    /* Clear the iPhone status bar / notch */
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .cg-form {
    /* Keep the input above the home indicator / Safari bottom bar */
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .cg-input {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
}
