:root {
  color-scheme: light;
  --ink: #2d1f1a;
  --muted: #8c7b6b;
  --line: #d9c8b4;
  --paper: #fdf6ee;
  --panel: #fffdf9;
  --accent: #8b4513;
  --accent-2: #5b7a3a;
  --soft: #f0e8d8;
  --risk: #b91c1c;
  --success: #3d6b35;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  background-image:
    linear-gradient(180deg, #fdf6ee 0%, #f5ead8 100%);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  position: relative;
}

/* 宣纸纹理质感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(139, 69, 19, 0.15) 3px,
      rgba(139, 69, 19, 0.15) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 5px,
      rgba(91, 122, 58, 0.1) 5px,
      rgba(91, 122, 58, 0.1) 6px
    );
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

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

button,
.admin-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 10px 14px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(139, 69, 19, 0.2);
  transition: box-shadow 0.2s, transform 0.15s;
}

button:hover,
.admin-link:hover {
  box-shadow: 0 3px 10px rgba(139, 69, 19, 0.3);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(91, 122, 58, 0.12);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

/* ========== Admin Layout ========== */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 253, 249, 0.97);
  border-right: 1px solid var(--line);
  padding: 24px 0 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 18px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand h1 {
  font-size: 18px;
  margin-top: 8px;
  line-height: 1.3;
}

.admin-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  box-shadow: none;
  border: none;
}

.nav-btn:hover {
  background: var(--soft);
  color: var(--accent);
  box-shadow: none;
  transform: none;
}

.nav-btn.active {
  background: var(--soft);
  color: var(--accent);
  font-weight: 700;
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.sidebar-footer {
  padding: 12px 10px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer .admin-link {
  display: block;
  text-align: center;
  font-size: 13px;
  padding: 8px 10px;
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
  overflow-y: auto;
}

.workspace,
.admin-card,
.quick-card,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 8px 28px rgba(139, 69, 19, 0.06);
}

/* 卡片顶部中式装饰线 */
.quick-card,
.admin-card {
  border-top: 3px solid var(--accent-2);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  background: var(--accent-2);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 3px;
  letter-spacing: 1px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0.5px;
}

h1 {
  color: var(--accent);
  font-size: 28px;
  font-family: "STKaiti", "KaiTi", "楷体", "Microsoft YaHei", serif;
  line-height: 1.4;
}

h2 {
  font-size: 18px;
  font-family: "STKaiti", "KaiTi", "楷体", "Microsoft YaHei", serif;
  color: var(--ink);
}

h3 {
  font-size: 15px;
  color: var(--accent-2);
}

.subcopy,
.hint {
  color: var(--muted);
  line-height: 1.6;
}

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

.ghost-button {
  background: var(--soft);
  color: var(--accent);
  box-shadow: none;
  border: 1px solid var(--line);
}

.ghost-button:hover {
  background: #e8dece;
  box-shadow: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  padding: 18px;
}

/* ========== Chat Panel ========== */

.chat-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 760px;
  overflow: hidden;
  border-top: 3px solid var(--accent);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 18px;
}

.message {
  max-width: 78%;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  background: var(--soft);
  border-left: 3px solid var(--accent-2);
  border-radius: 2px 8px 8px 2px;
}

.message.user {
  align-self: flex-end;
  background: #4a3228;
  color: #f5ead8;
  border-radius: 8px 2px 2px 8px;
  border-right: 3px solid var(--accent);
}

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

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(240, 232, 216, 0.4);
}

/* ========== Side Panel ========== */

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quick-card,
.admin-card {
  padding: 16px;
}

.sample-list,
.stacked-form,
.feature-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.sample-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sample-list button {
  background: var(--soft);
  color: var(--accent);
  box-shadow: none;
  border: 1px solid var(--line);
  font-size: 13px;
}

.sample-list button:hover {
  background: #e8dece;
  border-color: var(--accent);
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.check-line input {
  width: auto;
  margin-top: 4px;
  flex-shrink: 0;
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  min-height: 44px;
  padding: 12px;
}

.result-box:empty {
  display: none;
}

/* ========== Wizard (Step-by-step Consultation) ========== */

.wizard-step {
  margin-bottom: 12px;
}

.wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.wizard-actions button {
  flex: 1;
}

.wizard-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-2);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.consultation-final {
  margin-top: 12px;
}

.consultation-final h3 {
  margin-bottom: 8px;
}

/* ========== Tongue Upload ========== */

.tongue-guide {
  margin-bottom: 12px;
}

.guide-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.auth-notice {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #d4c9a0;
  border-radius: 8px;
  background: #faf5e4;
}

.tongue-upload-area {
  margin: 12px 0;
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s;
}

.upload-label:hover {
  border-color: var(--accent-2);
  background: var(--soft);
}

.upload-icon {
  font-size: 28px;
}

.tongue-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tongue-preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: contain;
}

.tongue-result-img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 6px;
  border: 1px solid var(--line);
  object-fit: contain;
  display: block;
  margin: 8px 0;
}

.tongue-thumb {
  max-width: 100px;
  max-height: 100px;
  border-radius: 6px;
  border: 1px solid var(--line);
  object-fit: contain;
  display: block;
  margin: 8px 0;
}

.upload-status {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.upload-status.success {
  color: var(--success);
}

.upload-status.error {
  color: var(--risk);
}

.feature-details {
  margin: 12px 0;
}

.feature-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

/* ========== Assessment ========== */

.assessment-text {
  padding: 10px;
  background: var(--panel);
  border-radius: 6px;
  border: 1px solid var(--line);
  line-height: 1.6;
  margin: 8px 0;
  font-size: 14px;
}

.assessment-followup {
  margin-top: 12px;
}

.assessment-followup pre {
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  line-height: 1.5;
  padding: 10px;
  white-space: pre-wrap;
  border: 1px solid var(--line);
}

/* ========== Admin Tabs ========== */

.tab-pane {
  display: none;
}

/* ========== 抽奖动画 ========== */
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.08); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

.tab-pane.active {
  display: block;
}

/* 线索/问诊/舌诊面诊 列表独立滚动 */
#leadList, #consultationList, #tongueList {
  max-height: calc(100vh - 360px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* ========== Admin ========== */

.admin-key {
  display: grid;
  grid-template-columns: minmax(240px, 360px) auto;
  gap: 10px;
  padding: 18px 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  border-left: 4px solid var(--accent-2);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 28px;
  font-family: "STKaiti", "KaiTi", "楷体", "Microsoft YaHei", serif;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
}

.record-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 14px;
}

.record p {
  margin: 8px 0;
}

.record pre {
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  line-height: 1.5;
  padding: 10px;
  white-space: pre-wrap;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record-head span {
  color: var(--accent-2);
  font-size: 13px;
}

.record-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.record-actions .field-label {
  margin: 0;
  white-space: nowrap;
}

.record-actions select {
  width: auto;
  min-width: 140px;
}

.review-btn,
.followup-done-btn {
  background: var(--accent-2);
  font-size: 13px;
  padding: 6px 12px;
}

.risk {
  color: var(--risk);
}

.empty {
  color: var(--muted);
  padding: 18px;
}

/* ========== Channel Stats ========== */

.channel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.channel-row:last-child {
  border-bottom: none;
}

.channel-name {
  min-width: 100px;
  font-size: 14px;
  color: var(--ink);
}

.channel-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--soft);
  border-radius: 4px;
  overflow: hidden;
}

.channel-bar {
  height: 100%;
  background: var(--accent-2);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.channel-count {
  min-width: 32px;
  text-align: right;
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}

/* ========== Landing Page ========== */

.landing-shell {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

.landing-hero {
  text-align: center;
  padding: 48px 16px 36px;
  position: relative;
}

/* 艾灸烟雾扩散装饰 */
.landing-hero::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(91, 122, 58, 0.06) 0%,
    rgba(139, 69, 19, 0.04) 40%,
    transparent 70%
  );
  pointer-events: none;
  z-index: -1;
}

.landing-hero h1 {
  font-size: 28px;
  line-height: 1.4;
}

.landing-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

.primary-cta {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(139, 69, 19, 0.25);
  transition: box-shadow 0.2s, transform 0.15s;
}

.primary-cta:hover {
  box-shadow: 0 5px 16px rgba(139, 69, 19, 0.35);
  transform: translateY(-1px);
}

.secondary-cta {
  display: inline-block;
  background: var(--soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--line);
  transition: background 0.2s;
}

.secondary-cta:hover {
  background: #e8dece;
}

.landing-band {
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.landing-band h2 {
  text-align: center;
  margin-bottom: 18px;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.landing-grid button,
.concern-grid button {
  background: var(--soft);
  color: var(--accent);
  padding: 14px 10px;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: none;
  transition: border-color 0.2s, background 0.2s;
}

.landing-grid button:hover,
.concern-grid button:hover {
  border-color: var(--accent);
  background: #e8dece;
  box-shadow: none;
  transform: none;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.price-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  border-top: 3px solid var(--accent-2);
}

.price-grid article strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
  font-family: "STKaiti", "KaiTi", "楷体", "Microsoft YaHei", serif;
}

.price-grid article span {
  display: block;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 8px;
}

.price-grid article p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 10px;
  line-height: 1.5;
}

.price-grid article button {
  width: 100%;
  font-size: 13px;
}

.landing-sticky {
  position: sticky;
  bottom: 0;
  text-align: center;
  padding: 14px;
  background: rgba(253, 246, 238, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.landing-sticky a {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 3px 12px rgba(139, 69, 19, 0.25);
  transition: box-shadow 0.2s, transform 0.15s;
}

.landing-sticky a:hover {
  box-shadow: 0 5px 18px rgba(139, 69, 19, 0.35);
  transform: translateY(-1px);
}

/* ========== Responsive ========== */

@media (max-width: 980px) {
  .content-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 540px;
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: column;
    padding: 12px 0 0;
  }

  .sidebar-brand {
    padding: 0 14px 12px;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 10px;
    gap: 4px;
  }

  .nav-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .nav-btn.active {
    border-left: none;
    border-bottom: 3px solid var(--accent);
    padding-left: 12px;
    padding-bottom: 7px;
  }

  .sidebar-footer {
    display: none;
  }

  .admin-main {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .record-head {
    flex-direction: column;
  }

  .sample-list,
  .feature-grid,
  .composer,
  .admin-key {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }

  .landing-hero h1 {
    font-size: 22px;
  }

  .landing-hero::before {
    width: 280px;
    height: 280px;
  }

  .landing-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

/* Acupoint prescription */
.acupoint-btn {
  margin-left: 10px;
  padding: 6px 14px;
  background: var(--accent-2, #8b6914);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.acupoint-btn:hover { filter: brightness(1.1); }
.acupoint-btn:disabled { opacity: .5; cursor: default; }
.acupoint-result { margin-top: 8px; }

/* Combined face + tongue step-by-step flow */
.combined-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 16px 0;
  padding: 12px 8px;
  background: var(--soft, #f8f8f8);
  border-radius: 12px;
  flex-wrap: wrap;
}
.cstep {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all .3s;
  opacity: .4;
}
.cstep.active {
  opacity: 1;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.cstep.done {
  opacity: .75;
}
.cstep-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ddd;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
}
.cstep.active .cstep-num {
  background: var(--accent, #e87722);
  color: #fff;
}
.cstep.done .cstep-num {
  background: #27ae60;
  color: #fff;
}
.cstep-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}
.cstep.active .cstep-label {
  color: #1a1a2e;
  font-weight: 600;
}
.cstep-arrow {
  font-size: 18px;
  color: #ccc;
  margin: 0 2px;
  padding-bottom: 16px;
}
.combined-step-panel {
  border-top: 1px solid var(--line, #e5e5e5);
  padding-top: 14px;
  margin-top: 4px;
}
.combined-step-panel h3 {
  font-size: 15px;
  margin: 0 0 12px;
  color: #1a1a2e;
}
.step-done-hint {
  margin-top: 12px;
  padding: 10px 14px;
  background: #eafaf1;
  border-radius: 8px;
  border: 1px solid #a3d9a5;
}
.step-done-hint .success-msg {
  color: #27ae60;
  font-weight: 600;
  margin: 0;
  font-size: 14px;
}
.combined-summary-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.combined-summary-card {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line, #e5e5e5);
  font-size: 13px;
  line-height: 1.6;
}
.combined-summary-card.face-card {
  background: #fef9e7;
  border-left: 3px solid #e87722;
}
.combined-summary-card.tongue-card {
  background: #f0f4ff;
  border-left: 3px solid #2980b9;
}
