﻿@import url("https://fonts.googleapis.com/css2?family=ZCOOL+XiaoWei&family=Work+Sans:wght@400;600;700&display=swap");

:root {
  --bg-1: #f8f1e8;
  --bg-2: #f6f7fb;
  --card: #fff8f2;
  --ink: #2b2a2a;
  --muted: #6d6a67;
  --accent: #e27d60;
  --accent-2: #3a7ca5;
  --ring: rgba(226, 125, 96, 0.35);
  --shadow: 0 10px 28px rgba(22, 20, 19, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 24px;
  font-family: "Work Sans", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 10% -10%, #ffe8d6 0%, transparent 60%),
              radial-gradient(900px 500px at 90% 10%, #e0f2ff 0%, transparent 55%),
              linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-size: 1200px 600px, 900px 500px, 100% 100%;
  background-attachment: fixed, fixed, fixed;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

header.hero {
  background: linear-gradient(135deg, #fff1e6, #f7fbff);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

header.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(226,125,96,0.25), transparent 65%);
  transform: rotate(12deg);
  pointer-events: none;
}

h1 {
  font-family: "Work Sans", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 32px;
  margin: 0 0 6px 0;
  letter-spacing: 1px;
}

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

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

.back-btn {
  border: 1px solid rgba(0,0,0,0.1);
  background: #fff;
  color: var(--accent-2);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
}

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

.auth-center {
  display: flex;
  justify-content: center;
  width: 100%;
}

.auth-card {
  width: min(420px, 92vw);
  margin: 0 auto;
}

.card {
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  animation: fadeUp 0.6s ease both;
}

.card h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
}

.card p {
  color: var(--muted);
  margin: 0 0 10px 0;
}

.row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.column {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.column input,
.column button {
  width: 100%;
}

.auth-form {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  max-width: 320px;
  margin: 0 auto;
}

.auth-form input,
.auth-form button {
  width: 100%;
}

.center {
  text-align: center;
}

.card-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

input, button, select, textarea {
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
  outline: none;
  background: #fff;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}

.btn.secondary { background: var(--accent-2); }
.btn.ghost {
  background: rgba(58,124,165,0.1);
  color: var(--accent-2);
  border: 1px solid rgba(58,124,165,0.25);
}

.btn:active { transform: translateY(1px); }

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

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(58,124,165,0.12);
  color: var(--accent-2);
  font-size: 12px;
  margin-left: 6px;
}

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

.status.ok { color: #2a7a52; }
.status.err { color: #b83b2f; }

.hint { font-size: 12px; color: var(--muted); }

.hidden { display: none; }

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.question-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 12px;
}

.question {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(0,0,0,0.06);
}

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.scale input { display: none; }

.scale label {
  text-align: center;
  padding: 6px 0;
  border-radius: 8px;
  background: #f3f3f3;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid rgba(0,0,0,0.06);
}

.scale input:checked + label {
  background: rgba(226,125,96,0.18);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: #ececec;
  overflow: hidden;
  margin: 8px 0 12px 0;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e27d60, #f6ae2d);
}

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

.pill {
  font-size: 12px;
  background: rgba(226,125,96,0.12);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
}

#chat-output {
  margin-top: 10px;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  min-height: 70px;
  border: 1px dashed rgba(0,0,0,0.08);
}

.chat-window {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  min-height: 280px;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid rgba(0,0,0,0.08);
}

.bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.bubble p {
  margin: 0 0 6px 0;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.bubble li {
  margin-bottom: 4px;
}

.bubble code {
  background: #f3f3f3;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.typing-cursor {
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 2px;
  background: rgba(43, 42, 42, 0.7);
  vertical-align: -2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.bubble.me {
  margin-left: auto;
  background: rgba(226,125,96,0.18);
  border: 1px solid rgba(226,125,96,0.3);
}

.bubble.bot {
  margin-right: auto;
  background: #f3f3f3;
  border: 1px solid rgba(0,0,0,0.06);
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.interp-list {
  display: grid;
  gap: 12px;
}

.interp-item {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.06);
}

.interp-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.interp-text {
  color: var(--muted);
  line-height: 1.6;
}

.chat-input-row textarea {
  height: 80px;
  resize: vertical;
}

/* Chat page: true viewport-adaptive layout */
body.chat-page {
  min-height: 100dvh;
}

body.chat-page .shell {
  min-height: calc(100dvh - 48px);
}

body.chat-page .chat-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  height: clamp(460px, calc(100dvh - 210px), 820px);
}

body.chat-page .chat-window {
  min-height: 0;
  max-height: none;
  height: auto;
}

body.chat-page .chat-input-row textarea {
  min-height: 64px;
  height: clamp(72px, 12dvh, 140px);
  max-height: 34dvh;
}

.chart-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 340px;
}

.chart-wrap #chart {
  width: 100%;
  max-width: 520px;
  height: 320px;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.nav a {
  text-decoration: none;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 13px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  body { padding: 16px; }
  .span-4, .span-5, .span-7, .span-8, .span-12 { grid-column: span 12; }
  h1 { font-size: 26px; }
  body.chat-page .shell {
    min-height: calc(100dvh - 32px);
  }
  body.chat-page .chat-card {
    height: clamp(430px, calc(100dvh - 180px), 760px);
  }
}
