:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667789;
  --line: #dce3ea;
  --line-strong: #b7c3cf;
  --primary: #136f63;
  --primary-dark: #0d554b;
  --danger: #c74d4d;
  --warning: #b7791f;
  --shadow: 0 16px 36px rgba(27, 40, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

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

button {
  border: 0;
}

.hidden {
  display: none !important;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-box {
  width: min(420px, 100%);
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-box h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0;
}

.auth-box p {
  margin: 0 0 22px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(19, 111, 99, 0.12);
}

.primary-btn,
.ghost-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--primary);
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.ghost-btn {
  color: var(--ink);
  background: #eef2f5;
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  border-color: var(--line-strong);
}

.voice-btn.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.danger-btn {
  color: #fff;
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.error-text {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.app {
  display: grid;
  grid-template-rows: 58px 1fr;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-weight: 900;
  overflow: hidden;
  line-height: 1;
}

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

.brand h1 {
  margin: 0;
  max-width: min(360px, 45vw);
  overflow: hidden;
  font-size: 18px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 280px;
  min-height: 0;
}

.conversation-list,
.chat-panel,
.info-panel,
.admin-main {
  min-height: 0;
  background: var(--panel);
}

.conversation-list {
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.list-header,
.info-section,
.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.list-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #ffffff;
}

.list-title {
  margin: 0;
  font-size: 15px;
}

.conversation-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  color: inherit;
  background: #fff;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef7f5;
}

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

.conversation-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  color: #fff;
  background: var(--danger);
  border-radius: 999px;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.conversation-meta,
.conversation-last,
.small-muted {
  color: var(--muted);
  font-size: 12px;
}

.conversation-last {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  background: #99a7b5;
  border-radius: 50%;
}

.status-dot.online {
  background: #13a36f;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-title {
  min-width: 0;
}

.chat-title h2 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  background: #f7f9fb;
}

.empty-chat {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.message {
  display: flex;
  align-items: flex-end;
  max-width: min(640px, 78%);
  gap: 10px;
}

.message.visitor {
  align-self: flex-start;
}

.message.agent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  background: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(27, 40, 54, 0.12);
  object-fit: cover;
}

.message-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.message.system {
  align-self: center;
  max-width: 80%;
  color: var(--muted);
  font-size: 12px;
}

.bubble {
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.5;
  word-break: break-word;
}

.message.agent .bubble {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.media-bubble {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.image-message {
  display: block;
  overflow: hidden;
  max-width: min(320px, 72vw);
  background: #eef2f5;
  border-radius: 8px;
}

.image-message img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.message.agent .image-message {
  background: rgba(255, 255, 255, 0.16);
}

.sticker-message {
  display: grid;
  place-items: center;
  min-width: 64px;
  min-height: 64px;
  padding: 8px 12px;
  font-size: 44px;
  line-height: 1;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message.agent .sticker-message {
  background: #e9f6f2;
  border-color: #b8d9d1;
}

.message-meta {
  color: var(--muted);
  font-size: 11px;
}

.message.agent .message-meta {
  text-align: right;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid var(--line);
}

.composer-tools {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 44px;
}

.tool-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--ink);
  background: #eef2f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.tool-btn:hover {
  border-color: var(--line-strong);
}

.emoji-panel {
  position: absolute;
  left: 0;
  bottom: 50px;
  z-index: 3;
  display: grid;
  gap: 10px;
  width: 276px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.emoji-section {
  display: grid;
  gap: 8px;
}

.emoji-section strong {
  color: var(--muted);
  font-size: 12px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.emoji-grid button {
  display: grid;
  place-items: center;
  height: 34px;
  background: #f5f7f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
}

.sticker-grid button {
  height: 42px;
  font-size: 26px;
}

.emoji-grid button:hover {
  background: #eef7f5;
  border-color: var(--primary);
}

.composer textarea {
  min-height: 44px;
  max-height: 120px;
}

.info-panel {
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.info-section {
  display: grid;
  gap: 10px;
}

.info-section h3 {
  margin: 0;
  font-size: 14px;
}

.info-row {
  display: grid;
  gap: 4px;
}

.info-row span {
  color: var(--muted);
  font-size: 12px;
}

.info-row strong,
.info-row a {
  color: var(--ink);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head h3 {
  min-width: 0;
}

.compact-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}

.quick-replies-section {
  gap: 12px;
}

.quick-form {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-form textarea {
  min-height: 76px;
  max-height: 150px;
  resize: vertical;
}

.quick-list {
  display: grid;
  gap: 8px;
}

.quick-item {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-item p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.offline-section {
  gap: 12px;
}

.offline-list {
  display: grid;
  gap: 8px;
}

.offline-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
}

.offline-item.done {
  border-left-color: var(--line-strong);
  opacity: 0.72;
}

.offline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.offline-head strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.offline-head span {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--primary);
  background: #e8f4f1;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.offline-item.done .offline-head span {
  color: var(--muted);
  background: #eef2f5;
}

.offline-item p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 0;
}

.admin-form {
  padding: 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.admin-main {
  overflow: auto;
}

.admin-section {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-section h2 {
  margin: 0;
  font-size: 16px;
}

.form-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.code-output {
  min-height: 112px;
  padding: 12px;
  color: #e8f4f1;
  background: #17202a;
  border: 0;
  border-radius: 8px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  vertical-align: -3px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 42, 0.42);
}

.modal-panel {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  padding: 18px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-grid {
  display: grid;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-item input {
  width: 18px;
  height: 18px;
}

.checkbox-item span {
  display: grid;
  gap: 2px;
}

.checkbox-item small {
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th {
  color: var(--muted);
  background: #f7f9fb;
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.demo-page {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(19, 111, 99, 0.12), transparent 42%),
    #f5f7f8;
}

.demo-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.demo-nav strong {
  font-size: 18px;
}

.demo-nav nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.demo-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.demo-nav a:hover {
  color: var(--primary);
}

.demo-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  align-items: center;
  gap: 42px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 58px 0 42px;
}

.demo-copy {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.demo-hero h1 {
  max-width: 680px;
  margin: 0 0 14px;
  font-size: clamp(32px, 7vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.demo-hero p {
  max-width: 620px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.demo-visual {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.browser-bar {
  display: flex;
  gap: 6px;
  padding: 12px;
  background: #edf2f4;
  border-bottom: 1px solid var(--line);
}

.browser-bar span {
  width: 10px;
  height: 10px;
  background: #9eb0bf;
  border-radius: 50%;
}

.visual-panel {
  position: relative;
  min-height: 360px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(19, 111, 99, 0.08), transparent),
    #ffffff;
}

.visual-line {
  width: 58%;
  height: 16px;
  margin-bottom: 12px;
  background: #dbe6e7;
  border-radius: 999px;
}

.visual-line.wide {
  width: 78%;
  height: 24px;
  background: #b8d2cc;
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 28px;
}

.visual-grid i {
  min-height: 86px;
  background: #f0f4f5;
  border: 1px solid #dce3ea;
  border-radius: 8px;
}

.visual-chat {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 220px;
  padding: 14px;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(19, 111, 99, 0.28);
}

.visual-chat b {
  display: block;
  margin-bottom: 6px;
}

.visual-chat p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.demo-section {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.demo-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.demo-section h2 {
  margin: 0;
  font-size: 28px;
}

.demo-section p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.demo-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.demo-cards article {
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.demo-cards h3 {
  margin: 0 0 8px;
}

.demo-cards p {
  margin: 0 0 18px;
}

.demo-cards strong {
  color: var(--primary);
  font-size: 20px;
}

.demo-faq {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.code-block {
  display: block;
  max-width: 100%;
  padding: 16px;
  overflow-x: auto;
  color: #e8f4f1;
  background: #17202a;
  border-radius: 8px;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .info-panel {
    display: none;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-form {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 260px minmax(0, 1fr);
  }

  .conversation-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    padding: 0 10px;
  }

  .top-actions {
    gap: 6px;
  }

  .ghost-btn,
  .primary-btn,
  .danger-btn {
    padding: 0 10px;
  }

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

  .composer-tools {
    grid-column: 1 / -1;
  }

  .emoji-panel {
    width: min(276px, calc(100vw - 28px));
  }

  .message {
    max-width: 90%;
  }

  .demo-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-hero,
  .demo-faq {
    grid-template-columns: 1fr;
  }

  .demo-visual {
    min-width: 0;
  }

  .demo-cards {
    grid-template-columns: 1fr;
  }

  .demo-section-head {
    align-items: start;
    flex-direction: column;
  }
}
