:root {
  --cc-chat-max: 58rem;
  --cc-chat-sidebar: 18rem;
  --cc-chat-composer-max: 56rem;
}

html:has(.cc-chat-body),
body.cc-chat-body {
  height: 100%;
  overflow: hidden;
}

body.cc-chat-body {
  min-height: 100dvh;
  margin: 0;
  padding: clamp(0rem, 2vw, 1.25rem);
  color: var(--cc-text);
  background:
    radial-gradient(circle at 12% 12%, rgba(0, 134, 255, 0.15), transparent 24rem),
    radial-gradient(circle at 90% 88%, rgba(235, 124, 58, 0.13), transparent 22rem),
    #eaf1f8;
}

.cc-chat-shell {
  width: min(100%, var(--cc-chat-max));
  height: calc(100dvh - clamp(0rem, 4vw, 2.5rem));
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: clamp(0rem, 3vw, var(--cc-radius-xl));
  background: var(--cc-surface);
  box-shadow: 0 1.6rem 5rem rgba(29, 41, 64, 0.18);
}

.cc-chat-topbar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: var(--cc-step-3);
  min-width: 0;
  padding: 0.8rem clamp(0.8rem, 3vw, 1.25rem);
  color: var(--cc-white);
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0.13), transparent 40%),
    linear-gradient(135deg, var(--cc-primary-active), var(--cc-primary));
  box-shadow: 0 0.55rem 1.5rem rgba(0, 90, 170, 0.18);
}

.cc-chat-avatar,
.cc-message-avatar {
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: var(--cc-surface);
}

.cc-chat-avatar {
  width: 3rem;
  height: 3rem;
  border: 2px solid rgba(255, 255, 255, 0.72);
}

.cc-chat-identity {
  min-width: 0;
}

.cc-chat-identity h1 {
  overflow: hidden;
  margin: 0;
  color: inherit;
  font-size: clamp(1rem, 3vw, 1.2rem);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-chat-presence {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.25rem 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.75rem;
}

.cc-chat-presence::before {
  width: 0.48rem;
  height: 0.48rem;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  content: "";
  background: #7ef1ae;
}

.cc-chat-topbar-action {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  flex: 0 0 auto;
  margin-left: auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--cc-white);
  background: rgba(255, 255, 255, 0.12);
  transition:
    background-color var(--cc-duration-fast) ease,
    transform var(--cc-duration-fast) var(--cc-ease-enter);
}

.cc-chat-topbar-action:hover {
  color: var(--cc-white);
  background: rgba(255, 255, 255, 0.23);
  transform: translateY(-1px);
}

.cc-chat-log {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1rem, 3vw, 1.5rem);
  scroll-behavior: smooth;
  background:
    radial-gradient(circle, rgba(0, 134, 255, 0.055) 1px, transparent 1.5px) 0 0 / 1.65rem 1.65rem,
    var(--cc-surface-alt);
  scrollbar-color: var(--cc-border-strong) transparent;
  scrollbar-width: thin;
}

.cc-chat-notice {
  width: fit-content;
  max-width: min(100%, 36rem);
  margin: 0 auto 1.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(0, 134, 255, 0.13);
  border-radius: var(--cc-radius-pill);
  color: var(--cc-primary-active);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.73rem;
  font-weight: 700;
  text-align: center;
  backdrop-filter: blur(10px);
}

.cc-chat-row {
  display: flex;
  max-width: min(88%, 43rem);
  align-items: flex-end;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  animation: cc-message-enter var(--cc-duration-normal) var(--cc-ease-enter) both;
}

.cc-chat-row.is-own {
  margin-left: auto;
  width: fit-content !important;
}

.cc-message-avatar {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--cc-border);
  box-shadow: var(--cc-shadow-sm);
}

.cc-chat-bubble {
  min-width: 0;
  padding: 0.72rem 0.9rem 0.55rem;
  border: 1px solid var(--cc-border);
  border-radius: 1.15rem 1.15rem 1.15rem 0.3rem;
  color: var(--cc-text);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0.2rem 0.8rem rgba(29, 41, 64, 0.06);
}

.cc-chat-row.is-own .cc-chat-bubble {
  border-color: transparent;
  border-radius: 1.15rem 1.15rem 0.3rem 1.15rem;
  color: var(--cc-white);
  background: linear-gradient(135deg, var(--cc-primary-active), var(--cc-primary));
}

.cc-chat-bubble.is-error {
  border-color: rgba(207, 59, 74, 0.25);
  color: #8d2530;
  background: #fff1f2;
}

.cc-chat-text {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(0.86rem, 2vw, 0.94rem);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.cc-chat-text a {
  color: var(--cc-primary-active);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.cc-chat-row.is-own .cc-chat-text a {
  color: inherit;
}

.cc-chat-text img,
.cc-chat-text video,
.cc-chat-text audio,
.cc-chat-text iframe,
.cc-chat-text table,
.cc-chat-text pre {
  max-width: 100%;
}

.cc-chat-text pre,
.cc-chat-text code {
  overflow-x: auto;
  white-space: pre;
}

.cc-chat-time {
  display: block;
  margin-top: 0.3rem;
  color: var(--cc-text-muted);
  font-size: 0.66rem;
}

.cc-chat-row.is-own .cc-chat-time {
  color: rgba(255, 255, 255, 0.72);
  text-align: right;
}

.cc-typing {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.65rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--cc-border);
  border-radius: 1.15rem 1.15rem 1.15rem 0.3rem;
  background: var(--cc-surface);
}

.cc-typing span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--cc-primary);
  animation: cc-typing 1.15s ease-in-out infinite;
}

.cc-typing span:nth-child(2) {
  animation-delay: 120ms;
}

.cc-typing span:nth-child(3) {
  animation-delay: 240ms;
}

.cc-chat-composer {
  position: relative;
  z-index: 4;
  padding:
    0.65rem clamp(0.7rem, 3vw, 1.15rem)
    calc(0.65rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--cc-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.cc-chat-compose-shell {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  max-width: var(--cc-chat-composer-max);
  margin-inline: auto;
  padding: 0.35rem;
  border: 1px solid var(--cc-border);
  border-radius: 1.5rem;
  background: var(--cc-surface-alt);
  transition:
    border-color var(--cc-duration-fast) ease,
    box-shadow var(--cc-duration-fast) ease;
}

.cc-chat-compose-shell:focus-within {
  border-color: var(--cc-primary);
  box-shadow: 0 0 0 3px var(--cc-primary-soft);
}

.cc-chat-compose-shell textarea {
  min-width: 0;
  min-height: 2.65rem;
  max-height: 10rem;
  flex: 1;
  resize: none;
  overflow-y: auto;
  padding: 0.62rem 0.65rem;
  border: 0;
  outline: 0;
  color: var(--cc-text);
  background: transparent;
  font: inherit;
  font-size: 0.91rem;
  line-height: 1.45;
}

.cc-chat-send,
.cc-chat-attach {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.cc-chat-send {
  color: var(--cc-white);
  background: var(--cc-primary);
  box-shadow: 0 0.4rem 1rem rgba(0, 134, 255, 0.25);
  transition:
    background-color var(--cc-duration-fast) ease,
    transform var(--cc-duration-fast) var(--cc-ease-enter);
}

.cc-chat-send:hover:not(:disabled) {
  background: var(--cc-primary-hover);
  transform: translateY(-1px);
}

.cc-chat-send:disabled {
  cursor: wait;
  opacity: 0.48;
  box-shadow: none;
}

.cc-chat-send .cc-icon,
.cc-chat-attach .cc-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.cc-chat-helper {
  margin: 0.35rem 0 0;
  color: var(--cc-text-muted);
  font-size: 0.68rem;
  text-align: center;
}

.cc-chat-workspace-body {
  padding: clamp(0rem, 1.5vw, 1rem);
}

.cc-chat-workspace {
  width: min(100%, 96rem);
  height: calc(100dvh - clamp(0rem, 3vw, 2rem));
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-inline: auto;
}

.cc-chat-panel {
  width: 100%;
  max-width: none;
  height: 100%;
}

.cc-chat-sidebar {
  display: none;
  min-height: 0;
  padding: 1.25rem;
  color: var(--cc-white);
  background:
    radial-gradient(circle at 30% 5%, rgba(0, 134, 255, 0.36), transparent 18rem),
    var(--cc-secondary);
}

.cc-chat-sidebar-brand {
  display: flex;
  min-height: 4rem;
  align-items: center;
  padding-inline: 0.55rem;
}

.cc-chat-sidebar-brand img {
  width: min(100%, 10rem);
  height: auto;
  max-height: 3rem;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
}

.cc-chat-sidebar-nav {
  display: grid;
  gap: 0.25rem;
  margin-top: 1.75rem;
}

.cc-chat-sidebar-nav > a,
.cc-chat-sidebar-nav summary {
  text-decoration: none !important;
  display: flex;
  min-height: 2.85rem;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--cc-radius-md);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
  font-weight: 680;
  cursor: pointer;
  list-style: none;
  transition:
    color var(--cc-duration-fast) ease,
    background-color var(--cc-duration-fast) ease,
    transform var(--cc-duration-fast) var(--cc-ease-enter);
}

.cc-chat-sidebar-nav summary::-webkit-details-marker {
  display: none;
}

.cc-chat-sidebar-nav > a:hover,
.cc-chat-sidebar-nav summary:hover,
.cc-chat-sidebar-nav details[open] > summary {
  color: var(--cc-white);
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(0.15rem);
}

.cc-chat-sidebar-nav .cc-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.cc-chat-sidebar-nav summary .cc-icon:last-child {
  margin-left: auto;
}

.cc-chat-sidebar-nav details[open] summary .cc-icon:last-child {
  transform: rotate(180deg);
}

.cc-chat-sidebar-nav details > div {
  max-height: 12rem;
  display: grid;
  gap: 0.1rem;
  overflow-y: auto;
  padding: 0.35rem 0 0.35rem 2.55rem;
}

.cc-chat-sidebar-nav details > div a {
  padding: 0.45rem 0.55rem;
  border-radius: var(--cc-radius-sm);
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.76rem;
}

.cc-chat-sidebar-nav details > div a:hover {
  color: var(--cc-white);
  background: rgba(255, 255, 255, 0.08);
}

.cc-chat-sidebar-user {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
  margin-top: auto;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--cc-radius-lg);
  background: rgba(255, 255, 255, 0.07);
}

.cc-chat-sidebar-user img {
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.cc-chat-sidebar-user div {
  min-width: 0;
}

.cc-chat-sidebar-user strong,
.cc-chat-sidebar-user small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-chat-sidebar-user strong {
  font-size: 0.82rem;
}

.cc-chat-sidebar-user small,
.cc-chat-sidebar-copy {
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.68rem;
}

.cc-chat-sidebar-copy {
  margin-top: 0.75rem;
  text-align: center;
}

.cc-chat-mobile-menu {
  position: relative;
  flex: 0 0 auto;
}

.cc-chat-mobile-menu > summary {
  margin: 0;
  list-style: none;
}

.cc-chat-mobile-menu > summary::-webkit-details-marker {
  display: none;
}

.cc-chat-mobile-menu > nav {
  position: absolute;
  top: calc(100% + 0.55rem);
  left: 0;
  z-index: 10;
  width: min(17rem, calc(100vw - 1.5rem));
  max-height: min(68dvh, 30rem);
  display: grid;
  gap: 0.2rem;
  overflow-y: auto;
  padding: 0.55rem;
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-lg);
  color: var(--cc-text);
  background: var(--cc-surface);
  box-shadow: var(--cc-shadow-lg);
}

.cc-chat-mobile-menu > nav a {
  display: flex;
  min-height: 2.7rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--cc-radius-md);
  color: var(--cc-text-soft);
  font-size: 0.82rem;
  font-weight: 680;
}

.cc-chat-mobile-menu > nav a:hover {
  color: var(--cc-primary-active);
  background: var(--cc-primary-soft);
}

.cc-chat-mobile-menu > nav .cc-icon {
  width: 1rem;
  height: 1rem;
}

.cc-chat-mobile-menu + .cc-chat-avatar {
  margin-left: 0;
}

.cc-chat-profile-link {
  margin-left: auto;
}

.cc-chat-file-preview {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem clamp(0.9rem, 3vw, 1.35rem);
  border-top: 1px solid var(--cc-border);
  color: var(--cc-text-soft);
  background: var(--cc-surface-alt);
  font-size: 0.78rem;
}

.cc-chat-file-preview[hidden] {
  display: none;
}

.cc-chat-file-preview > .cc-icon {
  width: 1rem;
  height: 1rem;
  color: var(--cc-primary);
}

.cc-chat-file-preview span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-chat-file-preview button {
  width: 2rem;
  height: 2rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--cc-text-muted);
  background: transparent;
  cursor: pointer;
}

.cc-chat-file-preview button:hover {
  color: var(--cc-danger);
  background: rgba(207, 59, 74, 0.09);
}

.cc-chat-file-preview button .cc-icon {
  width: 1rem;
  height: 1rem;
}

.cc-chat-attach {
  color: var(--cc-primary-active);
  background: transparent;
  transition:
    color var(--cc-duration-fast) ease,
    background-color var(--cc-duration-fast) ease;
}

.cc-chat-attach:hover:not(:disabled) {
  color: var(--cc-primary);
  background: var(--cc-primary-soft);
}

.cc-chat-attach:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.cc-chat-file-media {
  width: min(100%, 28rem);
  max-height: 22rem;
  display: block;
  overflow: hidden;
  margin-bottom: 0.55rem;
  border-radius: 0.8rem;
  object-fit: cover;
}

a.cc-chat-file-media img {
  width: 100%;
  max-height: 22rem;
  display: block;
  object-fit: cover;
}

.cc-chat-file-link {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid currentColor;
  border-radius: var(--cc-radius-md);
  color: inherit;
  background: rgba(255, 255, 255, 0.11);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.cc-chat-file-link .cc-icon {
  width: 1.2rem;
  height: 1.2rem;
  flex: 0 0 auto;
}

.cc-chat-file-link strong,
.cc-chat-file-link small {
  display: block;
}

.cc-chat-file-link small {
  margin-top: 0.1rem;
  opacity: 0.68;
}

.cc-chat-audio {
  width: min(100%, 24rem);
  display: block;
  margin-top: 0.55rem;
}

@keyframes cc-message-enter {
  from {
    opacity: 0;
    transform: translateY(0.45rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cc-typing {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-0.3rem);
  }
}

@media (max-width: 35.999rem) {
  body.cc-chat-body {
    padding: 0;
  }

  .cc-chat-shell {
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .cc-chat-row {
    max-width: 94%;
  }

  .cc-message-avatar {
    width: 1.8rem;
    height: 1.8rem;
  }

  .cc-chat-helper {
    display: none;
  }
}

@media (min-width: 48rem) {
  .cc-chat-workspace {
    grid-template-columns: var(--cc-chat-sidebar) minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--cc-radius-xl);
    box-shadow: 0 1.6rem 5rem rgba(29, 41, 64, 0.18);
  }

  .cc-chat-sidebar {
    display: flex;
    flex-direction: column;
  }

  .cc-chat-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .cc-chat-mobile-menu {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-chat-row,
  .cc-typing span {
    animation: none;
  }

  .cc-chat-log {
    scroll-behavior: auto;
  }
}
