:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #202321;
  --muted: #66736d;
  --line: #dce4e0;
  --accent: #78b93a;
  --accent-dark: #5d942b;
  --brand-dark: #00332c;
  --brand-deep: #00614b;
  --brand-gradient: linear-gradient(50.64deg, #00614b 0%, #00332c 100%);
  --soft: #f2f8ed;
  --soft-strong: #d8edc7;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 650;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #eef5f1;
  color: var(--brand-dark);
}

button.secondary:hover {
  background: #dcebe4;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
}

textarea {
  resize: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.shell {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebarBackdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  overflow: auto;
  overflow-x: hidden;
  border-right: 0;
  background: var(--brand-gradient);
  color: white;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand > div:last-child {
  min-width: 0;
}

.accountAvatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-weight: 800;
}

.sidebar .brand h1 {
  color: white;
}

.sidebar .brand p,
.sidebar .muted,
.sidebar .sectionTitle {
  color: rgba(255, 255, 255, 0.72);
}

.accountAvatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand h1,
.chatHeader h2 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.chatHeader p,
.muted {
  margin: 2px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.chatHeader h2,
.chatHeader p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.errorText {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.panel,
.uploadBox {
  display: grid;
  gap: 10px;
}

.newChatButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border-radius: 12px;
  font-size: 15px;
}

.newChatButton span {
  font-size: 16px;
}

.metaAuditRunButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 8px 12px;
  min-height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  background: transparent;
  color: rgba(148, 163, 184, 0.9);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.metaAuditRunButton:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.12);
  color: rgba(226, 232, 240, 0.95);
  border-color: rgba(148, 163, 184, 0.55);
}

.metaAuditRunButton:disabled {
  opacity: 0.6;
  cursor: default;
}

.sectionTitle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sectionTitleWithAction {
  justify-content: space-between;
}

.sectionTitleLabel {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
}

.sectionActionButton {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 24px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.sectionActionButton:hover {
  background: rgba(255, 255, 255, 0.24);
}

.refreshActionButton {
  position: relative;
  font-size: 0;
}

.refreshActionButton::before {
  content: "↻";
  font-size: 15px;
  line-height: 1;
}

.sectionIcon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: var(--accent);
  font-size: 13px;
}

.sectionSvgIcon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.fileIcon {
  position: relative;
  color: #4a730f;
}

.fileIcon {
  border: 1.7px solid currentColor;
  border-radius: 6px;
}

.fileIcon::before,
.fileIcon::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  height: 1.7px;
  border-radius: 999px;
  background: currentColor;
}

.fileIcon::before {
  top: 5px;
}

.fileIcon::after {
  top: 9px;
}

.sourceIcon {
  position: relative;
  border: 1.7px solid currentColor;
  border-radius: 999px;
}

.sourceIcon::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: currentColor;
}

.chatList,
.fileList {
  display: grid;
  gap: 6px;
}

#toolList {
  margin-top: 8px;
}

.fileChecking {
  color: var(--muted);
}

.fileChecking .typingDots {
  margin-left: 8px;
}

.chatItem,
.fileItem {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 9px 10px;
  text-align: left;
}

.chatItem {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.chatActions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.chatSelect {
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow-wrap: anywhere;
  border-radius: 0;
  background: transparent;
  color: white;
  padding: 0;
  text-align: left;
  white-space: normal;
}

.chatRenameInput {
  min-width: 0;
  padding: 2px 4px;
  border-radius: 7px;
  font-size: 13px;
}

.chatSelect:hover {
  background: transparent;
  color: white;
}

.chatItem.active {
  border-color: rgba(120, 185, 58, 0.72);
  background: rgba(120, 185, 58, 0.18);
}

.fileItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: default;
  overflow-wrap: anywhere;
}

.fileActions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.itemDownload {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 10px;
  background: rgba(120, 185, 58, 0.26);
  color: white;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
}

.itemDownload:hover {
  background: var(--accent);
  color: var(--brand-dark);
}

.fileItem span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sourceDetail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sourceStatusDot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #f2b84b;
}

.sourceStatusDot.connected {
  background: var(--accent);
}

.sourceStatusLabel {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.66);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.itemDelete {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 10px;
  background: rgba(255, 230, 228, 0.2);
  color: #ff8a80;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.itemDelete:hover {
  background: #b42318;
  color: white;
}

.itemEdit {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.78);
  padding: 0;
  font-size: 13px;
  line-height: 1;
}

.itemEdit:hover {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

.chatDelete {
  width: 22px;
  height: 22px;
  min-height: 22px;
  border-radius: 8px;
  font-size: 15px;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
}

.chatHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 18px 22px;
}

.chatHeaderLeft,
.chatHeaderRight {
  display: flex;
  align-items: center;
  min-width: 0;
}

.chatHeaderLeft {
  grid-column: 1;
  justify-self: start;
}

.chatHeaderRight {
  grid-column: 3;
  justify-content: flex-end;
  justify-self: end;
  width: max-content;
  position: relative;
  z-index: 3;
}

.chatHeaderCopy {
  min-width: 0;
  overflow: hidden;
}

.mobileMenuButton {
  display: none;
}

.headerLogo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 86px;
  max-height: 46px;
  object-fit: contain;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 26px 22px;
  background: #fbfcfb;
}

.message {
  max-width: min(820px, 92%);
  border: 1px solid #dfe8e3;
  border-radius: 14px;
  background: #f9fbfa;
  padding: 13px 16px;
  white-space: normal;
}

.message.assistant {
  border-color: #cdded6;
  background: #f7faf8;
  box-shadow: 0 1px 0 rgba(0, 51, 44, 0.05);
}

.message.user {
  align-self: flex-end;
  border-color: transparent;
  background: var(--brand-gradient);
  color: white;
}

.message.system {
  border-color: #f3c8c4;
  color: var(--danger);
}

.message.status {
  border-color: #cfdad4;
  background: #f7faf8;
  color: var(--muted);
}

.messageTableWrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 8px 0;
}

.copyTableButton {
  min-height: 28px;
  margin: 0 0 6px;
  border: 1px solid #cdded6;
  border-radius: 6px;
  background: #ffffff;
  color: var(--brand-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 650;
}

.copyTableButton:hover {
  background: #edf3f0;
}

.messageTable {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 13px;
}

.messageTable th,
.messageTable td {
  border: 1px solid #d6e4de;
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}

.messageTable th {
  background: #edf5f1;
  color: var(--brand-dark);
  font-weight: 750;
}

.messageTable tr:nth-child(even) td {
  background: #fbfdfc;
}

.loadingMessage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.typingDots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typingDots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  animation: typingBounce 1s infinite ease-in-out;
}

.typingDots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typingDots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "attachments attachments attachments"
    "attach input send";
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: white;
  padding: 14px 18px 18px;
}

.attachmentStrip {
  display: flex;
  grid-area: attachments;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.attachmentChip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  border: 1px solid #cdded6;
  border-radius: 999px;
  background: #f6faf8;
  padding: 7px 10px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 650;
}

.attachmentChip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachmentRemove {
  min-height: 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  background: #dbe8e2;
  color: var(--brand-dark);
  font-size: 16px;
  line-height: 1;
}

.attachmentRemove:hover {
  background: #c8dad1;
}

.messageAttachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.messageAttachment {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid #d6e4de;
  border-radius: 999px;
  background: #f5f8f7;
  color: var(--brand-dark);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messageAttachment:hover {
  background: #edf3f0;
}

.composer.dragActive {
  background: #f3faf5;
  box-shadow: inset 0 0 0 1px rgba(120, 185, 58, 0.28);
}

.composer textarea {
  grid-area: input;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  max-height: 180px;
  border-radius: 14px;
  background: #f7faf8;
  padding: 11px 12px;
}

.iconButton {
  display: grid;
  align-self: center;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
}

#attachButton {
  grid-area: attach;
  background: #eef5f1;
  font-size: 0;
  line-height: 0;
  position: relative;
}

#attachButton:hover {
  background: #dcebe4;
}

#attachButton::before,
#attachButton::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: var(--brand-dark);
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

#attachButton::before {
  width: 15px;
  height: 2.5px;
}

#attachButton::after {
  width: 2.5px;
  height: 15px;
}

#sendButton {
  grid-area: send;
  background: #20312c;
  color: #e9f0eb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#sendButton:hover {
  background: #15231f;
}

.hidden {
  display: none !important;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(23, 33, 29, 0.34);
  padding: 18px;
}

.modalBox {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  box-shadow: 0 18px 54px rgba(23, 33, 29, 0.18);
  padding: 18px;
}

.modalBox h3 {
  margin: 0;
  font-size: 17px;
}

.modalBox p {
  margin: 8px 0 18px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.modalActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dangerButton {
  background: var(--danger);
  color: white;
}

.dangerButton:hover {
  background: #8f1d14;
}

@media (max-width: 820px) {
  body {
    min-width: 0;
  }

  .shell {
    grid-template-columns: 1fr;
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 12;
    width: min(320px, 86vw);
    height: 100dvh;
    max-height: none;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    border-right: 0;
    box-shadow: 14px 0 38px rgba(0, 51, 44, 0.24);
    padding: 16px;
  }

  .shell.sidebarOpen .sidebar {
    transform: translateX(0);
  }

  .shell.sidebarOpen .sidebarBackdrop {
    position: fixed;
    inset: 0;
    z-index: 11;
    display: block;
    width: 100%;
    min-height: 0;
    border-radius: 0;
    background: rgba(23, 33, 29, 0.36);
    padding: 0;
  }

  .chat {
    height: 100dvh;
  }

  .chatHeader {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
    padding: 12px 12px;
  }

  .chatHeaderLeft,
  .chatHeaderRight {
    min-width: 0;
  }

  .chatHeaderCopy {
    min-width: 0;
  }

  .chatHeader h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chatHeader p {
    display: none;
  }

  .mobileMenuButton {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 20px;
  }

  .headerLogo {
    display: none;
  }

#logoutButton {
  margin-left: auto;
  min-height: 36px;
  padding: 7px 10px;
  white-space: nowrap;
}

  .messages {
    gap: 10px;
    padding: 14px 10px;
  }

  .message {
    max-width: 94%;
    border-radius: 12px;
    padding: 11px 12px;
  }

  .composer {
    align-items: flex-end;
    gap: 7px;
    padding: 10px 10px calc(34px + env(safe-area-inset-bottom));
  }

  .composer textarea {
    min-height: 50px;
    max-height: 128px;
    font-size: 16px;
    line-height: 1.35;
    padding: 13px 12px;
  }

  .composer button {
    font-size: 16px;
  }

  .iconButton {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
}

@media (max-width: 420px) {
  .brand h1,
  .chatHeader h2 {
    font-size: 16px;
  }

  .sidebar {
    width: min(300px, 88vw);
  }

  .message {
    max-width: 96%;
  }

  .composer {
    padding-inline: 8px;
    padding-bottom: calc(36px + env(safe-area-inset-bottom));
  }
}
