/* ============================================================
   app.css — 共享设计系统 v2
   覆盖：登录/注册 / 首页卡片 / 顶栏 / 聊天界面
   ============================================================ */

/* ---------- 设计变量与基础 ---------- */
:root {
  --green-50: #f2f9f4;
  --green-100: #dff0e6;
  --green-500: #2f9e63;
  --green-600: #1e8a50;
  --green-700: #126a3c;
  --teal: #2a9d8f;
  --amber: #f4a261;
  --ink: #1c2b22;
  --ink-2: #5b6f63;
  --ink-3: #93a49a;
  --line: rgba(28, 60, 44, 0.1);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow-sm: 0 2px 10px rgba(20, 60, 40, 0.06);
  --shadow: 0 12px 36px rgba(20, 60, 40, 0.12);
  --shadow-lg: 0 28px 70px rgba(20, 60, 40, 0.2);
  --grad: linear-gradient(135deg, #2f9e63, #1e8a50 55%, #2a9d8f);
  --font: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.6;
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(42, 157, 143, 0.16), transparent 60%),
    radial-gradient(900px 520px at -8% 112%, rgba(47, 158, 99, 0.14), transparent 55%),
    linear-gradient(165deg, #f7fbf8 0%, #eef6f1 55%, #eaf3ef 100%);
  background-attachment: fixed;
}

::selection {
  background: rgba(47, 158, 99, 0.25);
}

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

img {
  max-width: 100%;
  height: auto;
}

.app-empty {
  text-align: center;
  color: var(--ink-2);
  padding: 32px 0;
  font-size: 14px;
}

/* ---------- 认证页（登录/注册） ---------- */
.auth-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  padding: 40px 36px 34px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: auth-in 0.45s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 4px;
  border-radius: 0 0 8px 8px;
  background: var(--grad);
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.brand {
  text-align: center;
  margin-bottom: 22px;
}

.brand .logo {
  font-size: 44px;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(47, 158, 99, 0.35));
}

.brand h1 {
  font-size: 24px;
  color: var(--ink);
  margin: 8px 0 4px;
  letter-spacing: 0.5px;
}

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

.auth-tabs {
  display: flex;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tabs .tab {
  flex: 1;
  text-align: center;
  padding: 11px 10px;
  font-size: 15px;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: 0.2s;
  text-decoration: none;
  font-weight: 500;
}

.auth-tabs .tab.active {
  color: var(--green-600);
  border-bottom-color: var(--green-600);
  font-weight: 700;
}

.auth-tabs .tab:hover {
  color: var(--green-500);
}

.auth-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 14px 0 6px;
}

.auth-card input[type=text],
.auth-card input[type=password],
.auth-card input[type=email],
.auth-card input[type=tel] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ink);
  background: #fbfdfc;
  outline: none;
  transition: 0.2s;
}

.auth-card input:focus {
  border-color: var(--green-500);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 158, 99, 0.14);
}

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

.pw-row input {
  flex: 1;
}

.pw-row button {
  background: #f2f7f4;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
  transition: 0.2s;
}

.pw-row button:hover {
  background: var(--green-100);
}

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 13px 16px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(30, 138, 80, 0.32);
  transition: 0.25s;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(30, 138, 80, 0.42);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  display: block;
  text-align: center;
  padding: 11px;
  color: var(--ink-2);
  font-size: 14px;
  margin-top: 10px;
  border-radius: 11px;
  transition: 0.2s;
  text-decoration: none;
}

.secondary-btn:hover {
  background: rgba(47, 158, 99, 0.08);
  color: var(--green-600);
}

.text-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.8;
}

.text-btn:hover {
  opacity: 1;
}

.server-msg {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
  font-weight: 500;
}

.server-msg.success {
  display: block;
  background: #e7f6ec;
  color: var(--green-700);
  border: 1px solid #cdeeda;
}

.server-msg.error {
  display: block;
  background: #fdeeed;
  color: #c0392b;
  border: 1px solid #f6d5d2;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 24px;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(120deg, #12281d 0%, #1b3b2a 60%, #1e4a35 100%);
  box-shadow: 0 6px 22px rgba(10, 30, 20, 0.25);
}

.topbar-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

.badge {
  background: var(--grad);
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* ---------- 首页卡片 ---------- */
.home-main {
  max-width: 920px;
  margin: 44px auto;
  padding: 0 20px;
}

.home-main h2 {
  text-align: center;
  color: var(--ink);
  font-size: 28px;
  margin-bottom: 6px;
}

.home-main .sub {
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 34px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  max-width: 660px;
  margin: 0 auto;
}

.system-card {
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--r-lg);
  padding: 28px;
  cursor: pointer;
  transition: 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.system-card::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 158, 99, 0.16), transparent 65%);
}

.system-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(47, 158, 99, 0.4);
}

.card-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: linear-gradient(135deg, var(--green-100), #e9f3ee);
  border-radius: 18px;
  margin-bottom: 16px;
}

.system-card h3 {
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 6px;
}

.system-card p {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0;
}

.card-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--grad);
  color: #fff;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- 聊天 ---------- */
.chat-container {
  display: flex;
  height: calc(100vh - 62px);
  padding: 14px;
  max-width: 1200px;
  margin: 0 auto;
}

.chat-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-right: 14px;
  box-shadow: var(--shadow-sm);
}

.sidebar-header h3 {
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 2px;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--ink-2);
  margin: 0;
}

.sys-label,
.tool-label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 6px;
  font-weight: 600;
}

.sys-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-600);
}

.tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-chip {
  font-size: 11px;
  background: var(--green-50);
  color: var(--green-700);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--green-100);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  animation: msg-in 0.3s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.user-msg {
  justify-content: flex-end;
}

.bot-msg {
  justify-content: flex-start;
}

.system-msg {
  justify-content: center;
}

.msg-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.user-bubble {
  background: var(--grad);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 20px rgba(30, 138, 80, 0.28);
}

.bot-bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.system-bubble {
  background: #f0f6ff;
  border: 1px solid #dde7ff;
  text-align: center;
  font-size: 13px;
  color: #5a6b8c;
  max-width: 85%;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: typing 1.4s infinite;
}

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

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
  padding: 14px 18px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.icon-btn {
  background: #f2f7f4;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  cursor: pointer;
  font-size: 18px;
  transition: 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--green-100);
  transform: translateY(-1px);
}

.chat-input-area textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-size: 14px;
  resize: none;
  max-height: 130px;
  background: #fbfdfc;
  outline: none;
  transition: 0.2s;
  line-height: 1.5;
}

.chat-input-area textarea:focus {
  border-color: var(--green-500);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 158, 99, 0.12);
}

.send-btn {
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 12px 22px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: 0.22s;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(30, 138, 80, 0.28);
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(30, 138, 80, 0.36);
}

.send-btn:active {
  transform: none;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: rgba(47, 158, 99, 0.32);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(47, 158, 99, 0.5);
  background-clip: content-box;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .chat-container {
    height: calc(100vh - 58px);
    padding: 8px;
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    margin: 0 0 8px;
    overflow-x: auto;
  }

  .chat-sidebar > * {
    flex-shrink: 0;
  }

  .msg-bubble {
    max-width: 86%;
  }

  .auth-card {
    padding: 30px 22px 26px;
  }
}
