:root {
  --bg: #eef7f0;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-soft: rgba(224, 240, 226, 0.86);
  --ink: #17221a;
  --muted: #647269;
  --line: rgba(88, 125, 94, 0.18);
  --green: #2e6f3e;
  --green-deep: #254f2e;
  --green-soft: #dfeee2;
  --green-pale: #f4faf5;
  --moss: #6f8d4e;
  --amber: #b99448;
  --shadow: 0 18px 48px rgba(25, 54, 31, 0.14);
  --glass-shadow: 0 8px 30px rgba(25, 54, 31, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
}

.customer-page {
  position: relative;
  overflow: hidden;
  background: #dce8d5;
}

.customer-page::before {
  content: "";
  position: fixed;
  inset: -18px;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 22, 12, 0.14), rgba(238, 247, 240, 0.04) 34%, rgba(7, 19, 10, 0.2)),
    url("./caobian-bg.webp") 58% center / cover no-repeat fixed;
  filter: blur(10px) saturate(1.08);
  transform: scale(1.04);
}

.customer-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(238, 247, 240, 0.42), rgba(238, 247, 240, 0.12) 38%, rgba(238, 247, 240, 0.34)),
    radial-gradient(circle at 22% 8%, rgba(255, 255, 255, 0.34), transparent 28%);
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.phone-shell {
  position: relative;
  width: min(100%, 480px);
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(244, 250, 245, 0.06);
  border-inline: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow: 0 24px 70px rgba(9, 22, 13, 0.2);
}

.app-header,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
}

.top-glass-panel {
  flex: 0 0 auto;
  margin: 0 22px 12px;
  padding: calc(16px + env(safe-area-inset-top)) 22px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px double rgba(51, 51, 51, 0.08);
  border-radius: 0 0 30px 30px;
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
    inset 0 0 2px rgba(0, 0, 0, 0.52),
    0 4px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
}

.customer-page .app-header {
  padding: 0 0 12px;
}

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

.brand-mark-frame {
  position: relative;
  --tr: 25%;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px double rgba(51, 51, 51, 0.08);
  border-radius: 18px;
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
    inset 0 0 2px rgba(0, 0, 0, 0.52),
    0 4px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  filter: brightness(0.96);
}

.developer-entry {
  color: inherit;
  text-decoration: none;
}

.brand-mark-frame::before,
.status-card::before,
.message-bubble::before,
.composer-input-shell::before,
.send-button::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 35%;
  left: 50%;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  transform: translateX(-50%);
  pointer-events: none;
  border-radius: inherit;
  border: 1px solid rgba(0, 0, 0, 0.56);
  filter: blur(8px);
  opacity: 0.42;
}

.brand-mark-frame::after,
.status-card::after,
.message-bubble::after,
.composer-input-shell::after,
.send-button::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  filter: blur(3px);
  background: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.8) 0%,
    transparent var(--tr, 25%),
    transparent calc(100% - var(--tr, 25%)),
    rgba(255, 255, 255, 0.8) 100%
  );
}

.brand-mark-frame .circle-overlay,
.status-card .circle-overlay,
.message-bubble .circle-overlay,
.composer-input-shell .circle-overlay,
.send-button .circle-overlay {
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: inherit;
  filter: blur(1px);
}

.brand-mark {
  position: relative;
  z-index: 2;
  width: 43px;
  height: 43px;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(37, 79, 46, 0.12));
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
}

.send-button svg {
  position: relative;
  z-index: 2;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-card {
  position: relative;
  --tr: 18%;
  overflow: hidden;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 0;
  padding: 8px 12px;
  color: var(--green-deep);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px double rgba(51, 51, 51, 0.08);
  border-radius: 999px;
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
    inset 0 0 2px rgba(0, 0, 0, 0.52),
    0 4px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  filter: brightness(0.96);
}

.status-card > div {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(185, 148, 72, 0.12);
}

.status-dot.ready {
  background: #1f9d55;
  box-shadow: 0 0 0 4px rgba(31, 157, 85, 0.12);
}

.status-dot.warning {
  background: var(--amber);
}

#statusText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-window {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-glass-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin: 0 22px 0;
  overflow: hidden;
  border-top: 0;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(1px);
}

.message-row {
  display: flex;
  margin: 12px 0;
}

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

.message-bubble {
  position: relative;
  --tr: 15%;
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 26px;
  line-height: 1.58;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
    inset 0 0 2px rgba(0, 0, 0, 0.48),
    0 4px 8px rgba(0, 0, 0, 0.18);
}

.message-row.assistant .message-bubble {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(235, 246, 237, 0.62)),
    rgba(246, 252, 247, 0.66);
  border: 1px double rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.95),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.86),
    inset 0 0 2px rgba(46, 111, 62, 0.3),
    0 10px 24px rgba(8, 27, 13, 0.16);
  backdrop-filter: blur(14px) saturate(1.12);
  filter: brightness(1);
}

.message-row.user .message-bubble {
  color: #fff;
  background:
    linear-gradient(180deg, rgba(55, 130, 73, 0.72), rgba(30, 91, 48, 0.66)),
    rgba(36, 90, 50, 0.68);
  border: 1px double rgba(221, 245, 226, 0.4);
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.62),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.48),
    inset 0 0 2px rgba(7, 29, 14, 0.38),
    0 10px 24px rgba(8, 27, 13, 0.18);
  backdrop-filter: blur(14px) saturate(1.1);
  filter: brightness(0.98);
}

.message-row.assistant .message-bubble {
  border-top-left-radius: 12px;
}

.message-row.user .message-bubble {
  border-top-right-radius: 12px;
}

.message-source {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 8px;
  padding: 0 8px;
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
}

.message-text {
  position: relative;
  z-index: 2;
}

.typing {
  position: relative;
  z-index: 2;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 48px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  animation: typing 1s infinite ease-in-out;
}

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

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

@keyframes typing {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chat-composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: end;
  gap: 8px;
  padding: 8px 20px calc(10px + env(safe-area-inset-bottom));
  background: transparent;
  border-top: 0;
  backdrop-filter: none;
}

.composer-input-shell {
  position: relative;
  --tr: 15%;
  width: 100%;
  height: 42px;
  min-height: 42px;
  overflow: hidden;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  border: 1px double rgba(51, 51, 51, 0.08);
  border-radius: 24px;
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
    inset 0 0 2px rgba(0, 0, 0, 0.52),
    0 4px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  filter: brightness(0.98);
}

.chat-composer textarea {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 42px;
  max-height: 120px;
  min-height: 42px;
  padding: 10px 14px;
  overflow: hidden;
  resize: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 24px;
  outline: none;
}

.chat-composer textarea:focus,
.composer-input-shell:focus-within,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 111, 62, 0.16);
}

.send-button,
.primary-button,
.secondary-button,
.ghost-button,
.tab-button {
  border-radius: 18px;
  border: 1px solid transparent;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.send-button:active,
.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.tab-button:active {
  transform: translateY(1px);
}

.send-button {
  position: relative;
  --tr: 25%;
  overflow: hidden;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(32, 112, 55, 0.22);
  border: 1px double rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
    inset 0 0 2px rgba(0, 0, 0, 0.52),
    0 4px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  filter: brightness(0.94);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.admin-shell {
  width: min(100%, 980px);
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: 28px;
}

.text-link {
  flex: 0 0 auto;
  color: var(--green-deep);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 108px);
  padding: 20px;
}

.login-card,
.admin-panel {
  width: 100%;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(46, 111, 62, 0.16);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card {
  max-width: 420px;
  padding: 22px;
}

.login-card h2 {
  margin-bottom: 18px;
}

.admin-workspace {
  padding: 0 18px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(46, 111, 62, 0.16);
  border-radius: 8px;
}

.tab-button {
  flex: 1;
  min-height: 40px;
  color: var(--muted);
  background: transparent;
}

.tab-button.active {
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(46, 111, 62, 0.2);
}

.admin-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.knowledge-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.knowledge-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(46, 111, 62, 0.14);
  border-radius: 8px;
}

.knowledge-card h3 {
  margin: 0;
  font-size: 16px;
}

.knowledge-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.keyword-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-pill {
  padding: 4px 8px;
  color: var(--green-deep);
  font-size: 12px;
  background: var(--surface-soft);
  border-radius: 999px;
}

.card-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-form {
  display: grid;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(46, 111, 62, 0.18);
  border-radius: 8px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
  border: 0;
  box-shadow: none;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 9px 20px rgba(46, 111, 62, 0.2);
}

.secondary-button {
  color: var(--green-deep);
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(46, 111, 62, 0.2);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.form-hint,
.range-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  width: min(calc(100% - 32px), 420px);
  padding: 12px 14px;
  color: #fff;
  text-align: center;
  background: rgba(31, 43, 44, 0.92);
  border-radius: 8px;
  transform: translateX(-50%);
  box-shadow: var(--shadow);
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-heading .secondary-button {
    width: fit-content;
  }
}
  border-radius: 999px;
