:root {
  --bg: #eef2f8;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --line: #dde3ed;
  --line-strong: #c6cfdd;
  --text: #1f2937;
  --muted: #667085;
  --subtle: #98a2b3;
  --blue: #3370ff;
  --blue-weak: #e8f0ff;
  --purple: #7c3aed;
  --purple-weak: #f4edff;
  --green: #13a873;
  --danger: #d92d20;
  --field: #fbf9ff;
  --shadow: 0 24px 80px rgba(40, 55, 90, 0.14);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  overflow: hidden;
  background: #dfe6f1;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 72px 350px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #f5f7fb 0%, #eef2f8 100%);
  box-shadow: 0 28px 90px rgba(40, 55, 90, 0.22);
}

.app-shell.list-collapsed {
  grid-template-columns: 72px 0 minmax(0, 1fr);
}

.app-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 12px 10px;
  background: #dbe4f1;
  border-right: 1px solid #cbd5e1;
}

.window-dots {
  display: flex;
  gap: 7px;
  align-self: flex-start;
  padding: 2px 0 6px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.red {
  background: #ff5f57;
}

.yellow {
  background: #ffbd2e;
}

.green {
  background: #28c840;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  border: 0;
}

.user-avatar {
  background: linear-gradient(145deg, #2dd4bf, #2563eb);
}

.bot-face {
  background:
    radial-gradient(circle at 35% 24%, rgba(255, 255, 255, 0.95) 0 12%, transparent 13%),
    linear-gradient(145deg, #ff8a3d, #ffcd72);
  color: #8a3b00;
  font-size: 12px;
  letter-spacing: 0;
}

.large {
  width: 48px;
  height: 48px;
  font-size: 14px;
}

.rail-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.rail-item,
.menu-button,
.panel-menu-button,
.header-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #5b6574;
}

.rail-item {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.nav-icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-item.active {
  background: #f8fbff;
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(51, 112, 255, 0.08);
}

.rail-bottom {
  margin-bottom: 10px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid #d6dde8;
  overflow: hidden;
}

.app-shell.list-collapsed .conversation-list {
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
  visibility: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 42px;
}

.list-header h1 {
  margin: 0;
  flex: 1;
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0;
}

.menu-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.panel-menu-button {
  display: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.gradient-seven {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
}

.gradient-eight {
  background: linear-gradient(135deg, #f43f5e, #fb7185);
}

.gradient-nine {
  background: linear-gradient(135deg, #14b8a6, #0f766e);
}

.gradient-ten {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
}

.gradient-calendar {
  background: linear-gradient(135deg, #fb923c, #f97316);
}

.chat-items {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
  padding-top: 18px;
  padding-right: 2px;
}

.chat-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 10px;
  border-radius: 8px;
}

.chat-item.active {
  background: #dfeaff;
}

.chat-item.muted {
  background: #f1f3f6;
  margin-bottom: 8px;
}

.chat-item strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 16px;
  font-weight: 600;
}

.chat-item em,
.chat-title p {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--purple);
  background: var(--purple-weak);
  font-style: normal;
  font-size: 12px;
}

.chat-item p {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-item time {
  justify-self: end;
  color: var(--subtle);
  font-size: 13px;
  text-align: right;
}

.chat-panel {
  position: relative;
  display: flex;
  height: 100%;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
}

.chat-header {
  display: flex;
  flex: 0 0 76px;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  height: 76px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.app-shell.list-collapsed .panel-menu-button {
  display: inline-flex;
}

.chat-title {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 12px;
}

.chat-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
}

.chat-title p {
  margin: 6px 0 0;
}

.header-tools {
  display: flex;
  gap: 12px;
}

.header-tools button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.header-tools button:hover,
.menu-button:hover,
.panel-menu-button:hover,
.rail-item:hover,
.composer-actions button:hover {
  background: #eef3fb;
}

.chat-body {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 28px 28px 120px;
  background:
    linear-gradient(90deg, rgba(248, 250, 252, 0.8) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(0deg, rgba(248, 250, 252, 0.8) 1px, transparent 1px) 0 0 / 56px 56px,
    #fff;
}

.chat-body::-webkit-scrollbar {
  width: 8px;
}

.chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #c7d0df;
}

.chat-body::-webkit-scrollbar-thumb:hover {
  background: #aab6c8;
}

.welcome-message {
  margin-top: 18px;
}

.message-row {
  display: flex;
  gap: 10px;
  max-width: 980px;
  margin: 0 0 18px;
}

.message-row.user {
  justify-content: flex-end;
  margin-left: auto;
}

.message-row.agent {
  justify-content: flex-start;
}

.bubble {
  max-width: min(720px, calc(100vw - 620px));
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.65;
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.05);
}

.user .bubble {
  color: #fff;
  background: var(--blue);
}

.agent .bubble {
  border: 1px solid var(--line);
  background: #fff;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--subtle);
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.35;
  }

  40% {
    opacity: 1;
  }
}

.composer {
  flex: 0 0 auto;
  padding: 16px 28px 22px;
  border-top: 1px solid rgba(221, 227, 237, 0.85);
  background: rgba(255, 255, 255, 0.96);
}

.composer form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  min-height: 64px;
  padding: 10px 10px 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 40px;
  max-height: 150px;
  resize: none;
  border: 0;
  outline: 0;
  color: #344054;
  line-height: 1.55;
  overflow: hidden;
}

.composer-actions {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 4px;
  padding-bottom: 2px;
}

.composer-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667085;
}

.composer-actions .send-button {
  color: #fff;
  background: var(--blue);
}

.composer-actions .attach-button {
  color: #667085;
}

.contract-card {
  width: 640px;
  max-width: calc(100% - 50px);
  max-height: none;
  margin: 12px 0 20px;
  border: 1px solid #d9dde5;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 34px rgba(31, 41, 55, 0.08);
  font-size: 16px;
  overflow: visible;
}

.card-header {
  position: static;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 10px;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.96);
}

.eyebrow {
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.card-header h3 {
  margin: 0;
  color: #20252d;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  margin-top: 3px;
  padding: 5px 10px;
  border-radius: 8px;
  color: #5b21b6;
  background: #f2e9ff;
  font-size: 12px;
  font-weight: 600;
}

.form-section {
  padding: 8px 24px 2px;
}

.form-section + .form-section {
  border-top: 0;
}

.form-section h4 {
  margin: 8px 0 10px;
  padding: 0;
  border-left: 0;
  color: #4b5563;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #606a78;
  font-size: 14px;
  font-weight: 600;
}

label span b {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d7dbe2;
  border-radius: 9px;
  background: #fff;
  color: #242a33;
  outline: none;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.03);
}

input,
select {
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

textarea {
  min-height: 72px;
  padding: 9px 12px;
  resize: vertical;
  line-height: 1.6;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #3b6fff;
  box-shadow: 0 0 0 3px rgba(51, 112, 255, 0.16);
}

input.field-error,
select.field-error,
textarea.field-error {
  border-color: #f04438;
  background: #fff5f5;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.16);
}

input.field-error:focus,
select.field-error:focus,
textarea.field-error:focus {
  border-color: #d92d20;
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.22);
}

.ai-field textarea,
.contract-card input[value],
.contract-card select:has(option:checked:not([value=""])) {
  background: #fff;
}

.full,
.ai-field {
  grid-column: 1 / -1;
}

.inline-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #d7dbe2;
  border-radius: 9px;
  background: #fff;
}

.inline-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #242a33;
  font-size: 13px;
  font-weight: 500;
}

.inline-options input {
  width: auto;
  height: auto;
}

.compact {
  margin: 0;
}

.link-button {
  height: 28px;
  margin: 8px 14px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  font-weight: 500;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid #d7dbe2;
  border-radius: 9px;
  background: #fff;
}

.file-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 4px;
  background: #2f6fff;
  color: #fff;
  font-weight: 800;
}

.file-row strong {
  display: block;
  color: #344054;
}

.file-row small {
  color: var(--green);
}

.file-row .link-button {
  margin-left: auto;
}

.uploaded-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.uploaded-attachment strong {
  display: block;
  color: #fff;
  font-size: 14px;
}

.uploaded-attachment small {
  display: block;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.template-upload-card {
  width: 520px;
}

.template-upload-card .card-header {
  padding-bottom: 4px;
}

.template-upload-card .form-section {
  padding-top: 2px;
}

.template-upload-card .form-footer {
  padding-top: 14px;
}

.form-footer {
  position: static;
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 18px 24px 24px;
  border-top: 0;
  background: rgba(255, 255, 255, 0.96);
}

.form-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.primary-button {
  min-width: 112px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(51, 112, 255, 0.28);
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #b9c4d6;
  box-shadow: none;
}

.form-help a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.success-card {
  display: grid;
  gap: 10px;
  max-width: 560px;
  padding: 16px;
  border: 1px solid #b7e4d4;
  border-radius: 8px;
  background: #f3fbf8;
}

.success-card strong {
  color: #027a48;
}

.success-card a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.inline-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.icon-chat,
.icon-message,
.icon-search,
.icon-calendar,
.icon-doc,
.icon-file,
.icon-paperclip,
.icon-more,
.icon-menu,
.icon-plus,
.icon-window,
.icon-edit,
.icon-gear,
.icon-smile,
.icon-cut,
.icon-send {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
}

.icon-chat {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-chat::after {
  position: absolute;
  right: 1px;
  bottom: -3px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: inherit;
  transform: rotate(30deg);
  transform-origin: center;
  content: "";
}

.icon-chat::before {
  position: absolute;
  top: 6px;
  left: 5px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 10px 0 0 currentColor;
  content: "";
}

.icon-message {
  width: 21px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.icon-message::before {
  position: absolute;
  top: 6px;
  left: 5px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 10px 0 0 currentColor;
  content: "";
}

.icon-message::after {
  position: absolute;
  right: 2px;
  bottom: -5px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: inherit;
  transform: rotate(36deg);
  content: "";
}

.icon-search {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-search::after {
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 8px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  content: "";
}

.icon-calendar {
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon-calendar::before {
  position: absolute;
  top: 4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  content: "";
}

.icon-doc {
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-doc::after {
  position: absolute;
  top: 5px;
  left: 4px;
  width: 9px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor;
  content: "";
}

.icon-file {
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-file::before {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: #dbe4f1;
  content: "";
}

.icon-file::after {
  position: absolute;
  top: 7px;
  left: 4px;
  width: 9px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor;
  content: "";
}

.icon-paperclip {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-more::before {
  position: absolute;
  top: 8px;
  left: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 7px 0 0 currentColor, 14px 0 0 currentColor;
  content: "";
}

.icon-menu::before {
  position: absolute;
  top: 4px;
  left: 3px;
  width: 14px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
  content: "";
}

.icon-plus::before,
.icon-plus::after {
  position: absolute;
  top: 9px;
  left: 3px;
  width: 14px;
  height: 2px;
  background: currentColor;
  content: "";
}

.icon-plus::after {
  transform: rotate(90deg);
}

.icon-window {
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon-window::after {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 9px;
  height: 9px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  content: "";
}

.icon-edit {
  transform: rotate(-45deg);
}

.icon-edit::before {
  position: absolute;
  top: 3px;
  left: 8px;
  width: 5px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 2px;
  content: "";
}

.icon-gear {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-gear::after {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}

.icon-smile {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-smile::after {
  position: absolute;
  bottom: 4px;
  left: 5px;
  width: 7px;
  height: 4px;
  border-bottom: 2px solid currentColor;
  border-radius: 0 0 10px 10px;
  content: "";
}

.icon-cut::before,
.icon-cut::after {
  position: absolute;
  top: 2px;
  left: 9px;
  width: 2px;
  height: 17px;
  background: currentColor;
  transform: rotate(38deg);
  content: "";
}

.icon-cut::after {
  transform: rotate(-38deg);
}

.icon-send::before {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 16px solid currentColor;
  content: "";
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 64px 330px minmax(440px, 1fr);
  }

  .app-shell.list-collapsed {
    grid-template-columns: 64px 0 minmax(440px, 1fr);
  }

  .bubble {
    max-width: min(620px, calc(100vw - 440px));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .app-shell.list-collapsed {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .conversation-list {
    display: none;
  }

  .app-shell.list-collapsed .panel-menu-button {
    display: none;
  }

  .chat-header {
    height: 66px;
    padding: 0 14px;
  }

  .header-tools {
    gap: 4px;
  }

  .chat-body {
    padding: 18px 14px 110px;
  }

  .composer {
    padding: 10px 12px 14px;
  }

  .composer form {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    justify-content: flex-end;
  }

  .message-row {
    max-width: 100%;
  }

  .bubble {
    max-width: calc(100vw - 110px);
  }

  .contract-card {
    max-height: none;
    margin-left: 0;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .card-header,
  .form-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
