/* 派森小智 — 取自 Claude 设计系统：羊皮纸暖色调 + 衬线标题 */

:root {
  /* 颜色 */
  --parchment: #f5f4ed;
  --ivory: #faf9f5;
  --warm-sand: #e8e6dc;
  --border-cream: #f0eee6;
  --border-warm: #e8e6dc;
  --ring-warm: #d1cfc5;

  --text-primary: #141413;
  --text-secondary: #4d4c48;
  --text-tertiary: #87867f;

  --terracotta: #c96442;
  --terracotta-hover: #b1573a;
  --coral: #d97757;
  --error: #b53333;
  --focus: #3898ec;

  /* 字体 */
  --font-serif: Georgia, 'Times New Roman', 'Songti SC', 'SimSun', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  /* 形状 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --shadow-card: 0 0 0 1px var(--border-warm), 0 1px 2px rgba(20, 20, 19, 0.04);
  --shadow-elev: 0 0 0 1px var(--border-warm), 0 8px 24px rgba(20, 20, 19, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --parchment: #141413;
    --ivory: #1e1e1c;
    --warm-sand: #30302e;
    --border-cream: #2a2a28;
    --border-warm: #3d3d3a;
    --ring-warm: #4d4c48;

    --text-primary: #f5f4ed;
    --text-secondary: #b0aea5;
    --text-tertiary: #87867f;

    --shadow-card: 0 0 0 1px var(--border-warm), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-elev: 0 0 0 1px var(--border-warm), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--parchment);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--terracotta); text-decoration: none; }
a:hover { color: var(--terracotta-hover); text-decoration: underline; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea {
  font: inherit;
  color: inherit;
}

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 480px;
  background: var(--ivory);
  border-radius: var(--r-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-elev);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--terracotta);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.login-card h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.2;
  margin: 8px 0 4px;
}
.login-card .subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 15px;
}
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--parchment);
  border: 1px solid var(--border-warm);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(56, 152, 236, 0.2);
}
.row-inline {
  display: flex;
  gap: 8px;
}
.row-inline .input { flex: 1; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-weight: 500;
  font-size: 15px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  user-select: none;
}
.btn-primary {
  background: var(--terracotta);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--terracotta-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: var(--warm-sand);
  color: var(--text-primary);
}
.btn-secondary:hover { box-shadow: 0 0 0 1px var(--ring-warm); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 10px;
  font-size: 14px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--border-cream); border-radius: var(--r-sm); }
.btn-block { width: 100%; margin-top: 10px; }

.notice {
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--parchment);
  border-radius: var(--r-md);
  border-left: 3px solid var(--coral);
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.65;
}
.notice strong { color: var(--text-primary); }

.form-err {
  color: var(--error);
  font-size: 13px;
  margin-top: 6px;
  min-height: 18px;
}

/* ============ 聊天页 ============ */
.chat-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 100vh;   /* 锁死行高，防止内容把网格撑高带动 body 滚动 */
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  background: var(--ivory);
  border-right: 1px solid var(--border-warm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;               /* 允许 conv-list 的 overflow:auto 真正生效 */
}
.sidebar-mask { display: none; }  /* 桌面端默认隐藏，避免占用 grid 列 */
.sidebar-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-cream);
}
.sidebar-head .brand { margin-bottom: 16px; }
.sidebar-head .brand-logo { width: 36px; height: 36px; font-size: 20px; border-radius: 10px; }
.sidebar-head .brand-name { font-size: 18px; }

.btn-new {
  width: 100%;
  background: var(--terracotta);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-weight: 500;
}
.btn-new:hover { background: var(--terracotta-hover); }

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 8px 16px;
}
.conv-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  gap: 6px;
}
.conv-item:hover { background: var(--border-cream); color: var(--text-primary); }
.conv-item.active { background: var(--warm-sand); color: var(--text-primary); }
.conv-item .title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item .conv-act {
  visibility: hidden;
  color: var(--text-tertiary);
  font-size: 16px;
  padding: 0 4px;
}
.conv-item:hover .conv-act, .conv-item.active .conv-act { visibility: visible; }
.conv-item .conv-act:hover { color: var(--error); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border-cream);
  font-size: 13px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.id-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--parchment);
  border: 1px solid var(--border-warm);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* main */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--parchment);
}
.chat-head {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-cream);
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text-primary);
  background: var(--ivory);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-head .head-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 0;
}
.msg-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}
.msg {
  display: flex;
  gap: 14px;
  margin-bottom: 28px;
  align-items: flex-start;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 500;
}
.msg.user .avatar { background: var(--warm-sand); color: var(--text-primary); }
.msg.assistant .avatar { background: var(--terracotta); color: #fff; font-family: var(--font-serif); font-size: 18px; }
.bubble {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text-primary);
  word-wrap: break-word;
}
.msg.user .bubble { color: var(--text-primary); }
.bubble > *:first-child { margin-top: 0; }
.bubble > *:last-child { margin-bottom: 0; }

.bubble h1, .bubble h2, .bubble h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.3;
  margin: 1.2em 0 0.5em;
}
.bubble h1 { font-size: 1.6em; }
.bubble h2 { font-size: 1.35em; }
.bubble h3 { font-size: 1.15em; }
.bubble p { margin: 0.75em 0; }
.bubble ul, .bubble ol { margin: 0.6em 0; padding-left: 1.5em; }
.bubble li { margin: 0.2em 0; }
.bubble blockquote {
  border-left: 3px solid var(--ring-warm);
  padding: 2px 14px;
  margin: 1em 0;
  color: var(--text-secondary);
  background: var(--ivory);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.bubble code {
  font-family: var(--font-mono);
  background: var(--warm-sand);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}
.bubble pre {
  position: relative;
  background: #1f1e1c;
  color: #f5f4ed;
  padding: 16px 18px;
  border-radius: var(--r-md);
  overflow-x: auto;
  margin: 1em 0;
  font-size: 13.5px;
  line-height: 1.6;
}
.bubble pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
}
.bubble pre .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: rgba(245, 244, 237, 0.08);
  color: #b0aea5;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}
.bubble pre:hover .copy-btn { opacity: 1; }
.bubble pre .copy-btn:hover { background: rgba(245, 244, 237, 0.18); color: #f5f4ed; }

.bubble table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 14px;
}
.bubble th, .bubble td {
  border: 1px solid var(--border-warm);
  padding: 6px 12px;
}
.bubble th { background: var(--warm-sand); }

.cursor::after {
  content: '▍';
  color: var(--terracotta);
  animation: blink 1s steps(1) infinite;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* 空态 */
.empty-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}
.empty-state h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 28px;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.empty-state p { margin: 0; max-width: 420px; font-size: 15px; }
.empty-state .examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 560px;
  width: 100%;
  margin-top: 28px;
}
.example-card {
  text-align: left;
  background: var(--ivory);
  border: 1px solid var(--border-warm);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: box-shadow 0.15s, color 0.15s;
}
.example-card:hover {
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

/* 输入区 */
.composer-wrap {
  border-top: 1px solid var(--border-cream);
  background: var(--ivory);
  padding: 16px 24px 20px;
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--parchment);
  border: 1px solid var(--border-warm);
  border-radius: var(--r-lg);
  padding: 10px 12px 10px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.composer:focus-within {
  border-color: var(--ring-warm);
  box-shadow: 0 0 0 4px rgba(201, 100, 66, 0.08);
}
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 15.5px;
  line-height: 1.6;
  padding: 8px 0;
  min-height: 24px;
  max-height: 200px;
  font-family: inherit;
}
.send-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--terracotta);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--terracotta-hover); }
.send-btn:disabled { background: var(--ring-warm); cursor: not-allowed; }
.composer-hint {
  max-width: 760px;
  margin: 8px auto 0;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

/* 响应式 */
@media (max-width: 720px) {
  .chat-app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow-elev);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 19;
    display: none;
  }
  .sidebar.open + .sidebar-mask { display: block; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }
