/* ============================================================
   BLACK BEAN · 黑豆 — 极简古风
   宣纸为底，浓墨为文，黛青点睛；去繁就简，以留白为美
   ============================================================ */
:root {
  --paper: #f6f1e3;          /* 宣纸 */
  --paper-2: #efe8d3;        /* 旧纸 */
  --paper-3: #fcf8ee;        /* 笺纸（卡片） */
  --ink: #33302a;            /* 浓墨 */
  --ink-2: #6d6759;          /* 中墨 */
  --ink-3: #a39c8a;          /* 淡墨 */
  --jade: #3a7d6b;           /* 黛青（唯一点缀） */
  --jade-soft: rgba(58, 125, 107, 0.08);
  --clay: #96633f;           /* 赭石（警示/失败） */
  --clay-soft: rgba(150, 99, 63, 0.1);
  --line: rgba(51, 48, 42, 0.11);
  --line-strong: rgba(51, 48, 42, 0.26);
  --radius: 6px;
  --radius-sm: 4px;
  --sidebar-width: 260px;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "FangSong", "STFangsong", monospace;
  --kai: "KaiTi", "STKaiti", "楷体", "SimSun", serif;          /* 楷书 */
  --song: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif; /* 宋体 */
  --sans: var(--song);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--song);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  letter-spacing: 0.02em;
}

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

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--jade);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(51, 48, 42, 0.18);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(51, 48, 42, 0.3);
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   侧边栏
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 14px;
  border-bottom: 1px solid var(--line);
}

/* 墨点 */
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #4a453b, var(--ink));
  color: var(--paper);
  display: grid;
  place-items: center;
  font-family: var(--kai);
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(51, 48, 42, 0.3);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.brand-copy strong {
  font-family: var(--kai);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink);
}

.brand-copy span {
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--kai);
  font-size: 14px;
  letter-spacing: 0.15em;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.new-chat-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.new-chat-btn svg {
  width: 15px;
  height: 15px;
}

/* 会话搜索 */
.sidebar-search {
  position: relative;
}

.sidebar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 30px;
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  transition: border-color 0.12s ease;
}

.sidebar-search input::placeholder {
  color: var(--ink-3);
}

.sidebar-search input:focus {
  border-color: var(--jade);
  outline: none;
}

.sidebar-label {
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.25em;
  padding: 0 2px;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 40px;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.session-item:hover {
  background: rgba(51, 48, 42, 0.05);
}

.session-item.active {
  background: var(--paper-3);
  border-left-color: var(--jade);
}

.session-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.session-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-family: var(--kai);
}

.session-item-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
  font-size: 11px;
}

.session-item time {
  color: var(--ink-3);
  font-size: 11px;
  flex: 0 0 auto;
}

.session-delete {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.session-item:hover .session-delete,
.session-item.active .session-delete {
  opacity: 1;
}

.session-delete:hover {
  background: var(--clay-soft);
  color: var(--clay);
}

.session-delete svg {
  width: 13px;
  height: 13px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.model-chip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--ink-2);
  font-family: var(--kai);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  transition: color 0.12s ease, background 0.12s ease;
}

.icon-btn:hover {
  color: var(--ink);
  background: rgba(51, 48, 42, 0.06);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

/* ============================================================
   主区域
   ============================================================ */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background:
    radial-gradient(1000px 460px at 85% -10%, rgba(58, 125, 107, 0.05), transparent 60%),
    var(--paper);
}

/* 顶栏 */
.topbar {
  height: 54px;
  flex: 0 0 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 241, 227, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.menu-btn {
  display: none;
}

.topbar-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.topbar-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--kai);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.topbar-sub {
  color: var(--ink-3);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ctx-chip {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
}

/* 状态 */
.topbar-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12px;
  font-family: var(--kai);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 6px rgba(58, 125, 107, 0.4);
  transition: background 0.2s ease;
}

.status-dot.busy {
  background: var(--jade);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-dot.error {
  background: var(--clay);
  box-shadow: 0 0 6px rgba(150, 99, 63, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

/* ============================================================
   协作任务面板
   ============================================================ */
.coop-panel {
  flex: 0 0 auto;
  padding: 8px 18px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(239, 232, 211, 0.7);
}

.coop-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  cursor: pointer;
  user-select: none;
}

.coop-panel.collapsed .coop-list {
  display: none;
}

.coop-panel.collapsed {
  padding-bottom: 6px;
}

.coop-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--kai);
  letter-spacing: 0.12em;
  color: var(--ink-2);
}

.coop-panel-title svg {
  width: 14px;
  height: 14px;
  color: var(--jade);
}

.coop-panel-count {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--kai);
}

.coop-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.coop-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-3);
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 0.15s ease;
}

.coop-card.running {
  border-color: rgba(58, 125, 107, 0.45);
}

.coop-card-main {
  display: flex;
  align-items: center;
  gap: 9px;
}

.coop-card-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--ink-3);
}

.coop-card-dot.running {
  background: var(--jade);
  animation: pulse 1.1s ease-in-out infinite;
}

.coop-card-dot.done {
  background: var(--jade);
}

.coop-card-dot.failed {
  background: var(--clay);
}

.coop-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.coop-card-title {
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--kai);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coop-card-meta {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coop-card-meta code {
  font-family: var(--mono);
  color: var(--jade);
}

.coop-card-state {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--kai);
  padding: 1px 8px;
  border-radius: 999px;
}

.coop-card-state.running {
  color: var(--jade);
  background: var(--jade-soft);
}

.coop-card-state.done {
  color: var(--jade);
  background: var(--jade-soft);
}

.coop-card-state.failed {
  color: var(--clay);
  background: var(--clay-soft);
}

.coop-card-progress {
  height: 3px;
  border-radius: 999px;
  background: rgba(51, 48, 42, 0.08);
  overflow: hidden;
}

.coop-card-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--jade);
  transition: width 0.4s ease;
}

.coop-card.failed .coop-card-progress-bar {
  background: var(--clay);
}

/* ============================================================
   任务时间轴
   ============================================================ */
.timeline {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0 16px;
  scroll-behavior: smooth;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  color: var(--ink-2);
  padding: 0 24px;
}

.empty-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: var(--ink-2);
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state h1 {
  color: var(--ink);
  font-family: var(--kai);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin: 0;
}

.empty-state p {
  max-width: 440px;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.9;
}

.examples {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(100%, 380px);
  margin-top: 8px;
}

.example {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--kai);
  text-align: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.example:hover {
  color: var(--jade);
  border-bottom-color: var(--jade);
}

/* 加载更早消息 */
.load-earlier {
  display: block;
  margin: 4px auto 14px;
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--ink-2);
  font-family: var(--kai);
  font-size: 12px;
  letter-spacing: 0.08em;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.load-earlier:hover {
  color: var(--jade);
  border-color: rgba(58, 125, 107, 0.45);
}

.load-earlier:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ===== 任务块 ===== */
.task {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 26px;
}

.task-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0 12px;
}

.task-badge {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  margin-top: 5px;
}

.task-badge svg {
  width: 11px;
  height: 11px;
}

.task-text {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  font-family: var(--kai);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.task-text code {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--jade);
}

.task-text a {
  color: var(--jade);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.task-text img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* ===== 步骤时间轴 ===== */
.task-steps {
  position: relative;
  padding-left: 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-steps::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--line-strong);
}

.step {
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.step:hover {
  background: var(--paper-3);
  border-color: var(--line);
}

.step.running {
  background: var(--paper-3);
  border-color: rgba(58, 125, 107, 0.4);
}

.step-dot {
  position: absolute;
  left: -27px;
  top: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-3);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.step.running .step-dot {
  background: var(--jade);
  box-shadow: 0 0 0 1px var(--jade);
  animation: pulse 1.1s ease-in-out infinite;
}

.step.success .step-dot {
  background: var(--jade);
  box-shadow: 0 0 0 1px var(--jade);
}

.step.failed .step-dot {
  background: var(--clay);
  box-shadow: 0 0 0 1px var(--clay);
}

.step-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  cursor: pointer;
  user-select: none;
}

.step-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--ink-2);
}

.step-icon svg {
  width: 12px;
  height: 12px;
}

.step.running .step-icon {
  color: var(--jade);
}

.step-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.step-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--kai);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.step.running .step-state {
  color: var(--jade);
}

.step.success .step-state {
  color: var(--jade);
}

.step.failed .step-state {
  color: var(--clay);
}

.step-time {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--mono);
  white-space: nowrap;
}

/* 展开 / 收起按钮 */
.step-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--kai);
  font-size: 11px;
  letter-spacing: 0.06em;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.step-toggle:hover {
  color: var(--jade);
  border-color: rgba(58, 125, 107, 0.45);
  background: var(--jade-soft);
}

.step-toggle .step-chevron {
  width: 10px;
  height: 10px;
  transition: transform 0.15s ease;
}

.step.open .step-toggle .step-chevron {
  transform: rotate(90deg);
}

.step-body {
  display: none;
  border-top: 1px dashed var(--line);
  max-height: 320px;
  overflow-y: auto;
}

.step.open .step-body {
  display: block;
}

.step-section {
  padding: 8px 11px;
  border-bottom: 1px dashed var(--line);
}

.step-section:last-child {
  border-bottom: 0;
}

.step-section-label {
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--kai);
  letter-spacing: 0.12em;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-section-label .tick {
  color: var(--jade);
  font-size: 12px;
  letter-spacing: 0;
}

.step-section-label .cross {
  color: var(--clay);
  font-size: 12px;
  letter-spacing: 0;
}

.step-section pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: #4a463c;
}

.step-section pre.output-empty {
  color: var(--ink-3);
  font-style: italic;
}

/* ===== 输出面板 ===== */
.task-output {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding: 16px 2px 0;
}

.assistant-text {
  font-size: 14.5px;
  line-height: 1.9;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.assistant-text h1,
.assistant-text h2,
.assistant-text h3 {
  font-family: var(--kai);
  font-weight: 700;
  margin: 18px 0 8px;
  line-height: 1.4;
}

.assistant-text h1 {
  font-size: 19px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.assistant-text h2 { font-size: 17px; }
.assistant-text h3 { font-size: 15px; }

.assistant-text p {
  margin: 8px 0;
}

.assistant-text a {
  color: var(--jade);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.assistant-text a:hover {
  color: #2b6152;
}

.assistant-text img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

.assistant-text del {
  color: var(--ink-3);
}

.assistant-text em {
  font-style: italic;
}

.assistant-text ul,
.assistant-text ol {
  margin: 8px 0;
  padding-left: 24px;
}

.assistant-text li {
  margin: 3px 0;
}

.assistant-text code {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--jade);
}

.assistant-text pre {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  line-height: 1.65;
}

.assistant-text pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12.5px;
  color: var(--ink);
}

/* 代码块 + 复制按钮 */
.code-block {
  position: relative;
  margin: 10px 0;
}

.code-block pre {
  margin: 0;
  padding-top: 34px;
}

.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-3);
  color: var(--ink-2);
  font-family: var(--kai);
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-block:hover .code-copy,
.code-copy:focus-visible {
  opacity: 1;
}

.code-copy:hover {
  color: var(--jade);
  border-color: rgba(58, 125, 107, 0.45);
}

.assistant-text blockquote {
  margin: 10px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--jade);
  background: var(--jade-soft);
  border-radius: 0 4px 4px 0;
  color: var(--ink-2);
}

.assistant-text table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 13px;
}

.assistant-text th,
.assistant-text td {
  border: 1px solid var(--line);
  padding: 7px 12px;
  text-align: left;
}

.assistant-text th {
  background: var(--paper-2);
  font-weight: 600;
  font-family: var(--kai);
}

.assistant-text hr {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 16px 0;
}

.typing-caret::after {
  content: "▍";
  color: var(--jade);
  animation: blink 0.9s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.answer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 10px;
  font-family: var(--kai);
  letter-spacing: 0.06em;
}

.answer-meta .meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-3);
}

.answer-meta svg {
  width: 11px;
  height: 11px;
  color: var(--jade);
}

/* ===== 通知 & 错误 ===== */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.7;
  padding: 9px 13px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  margin: 8px auto;
  background: var(--jade-soft);
  max-width: 780px;
  word-break: break-word;
}

.notice::before {
  content: "i";
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border-radius: 50%;
  background: var(--jade);
  color: var(--paper);
  font-weight: 700;
  font-size: 10px;
  font-family: Georgia, serif;
  margin-top: 2px;
}

.error-message {
  color: var(--clay);
  border: 1px solid rgba(150, 99, 63, 0.35);
  background: var(--clay-soft);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 13px;
  margin: 8px auto;
  max-width: 780px;
  word-break: break-word;
}

/* ============================================================
   返回底部按钮
   ============================================================ */
.scroll-bottom {
  position: absolute;
  right: 30px;
  bottom: 100px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper-3);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 12px rgba(51, 48, 42, 0.18);
  z-index: 10;
  transition: color 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}

.scroll-bottom:hover {
  color: var(--jade);
  border-color: rgba(58, 125, 107, 0.45);
}

.scroll-bottom:active {
  transform: scale(0.94);
}

.scroll-bottom svg {
  width: 15px;
  height: 15px;
}

/* ============================================================
   输入台（砚台）
   ============================================================ */
.composer-wrap {
  flex: 0 0 auto;
  padding: 10px 24px 16px;
}

.composer {
  max-width: 780px;
  margin: 0 auto;
  background: var(--paper-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px 9px;
  box-shadow: 0 1px 3px rgba(51, 48, 42, 0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer:focus-within {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px var(--jade-soft);
}

.composer textarea {
  width: 100%;
  border: 0;
  background: none;
  color: var(--ink);
  resize: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
  max-height: 180px;
  padding: 2px 4px 8px;
}

.composer textarea::placeholder {
  color: var(--ink-3);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-hint {
  color: var(--ink-3);
  font-size: 11px;
  margin-right: auto;
  font-family: var(--kai);
  letter-spacing: 0.06em;
}

.send-btn,
.stop-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transition: background 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

/* 投递 — 墨钮 */
.send-btn {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 2px 8px rgba(51, 48, 42, 0.3);
}

.send-btn:hover {
  background: var(--jade);
}

.send-btn:active {
  transform: scale(0.92);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* 停止 — 赭描边 */
.stop-btn {
  border: 1px solid var(--line-strong);
  color: var(--clay);
}

.stop-btn:hover {
  background: var(--clay-soft);
}

.send-btn svg,
.stop-btn svg {
  width: 15px;
  height: 15px;
}

.disclaimer {
  text-align: center;
  color: var(--ink-3);
  font-size: 11px;
  margin: 8px 0 0;
  font-family: var(--kai);
  letter-spacing: 0.06em;
}

.hidden {
  display: none !important;
}

/* ============================================================
   弹窗
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 37, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 500px;
  background: var(--paper-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(40, 37, 30, 0.25);
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}

.modal-header strong {
  font-size: 14px;
  font-family: var(--kai);
  letter-spacing: 0.2em;
  color: var(--ink);
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 66vh;
  overflow-y: auto;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.settings-group-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--jade);
  font-family: var(--kai);
  letter-spacing: 0.14em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.modal-label {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  font-family: var(--kai);
}

.modal-body input,
.modal-body select {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 8px 11px;
  font: inherit;
  font-size: 12.5px;
  transition: border-color 0.12s ease;
}

.modal-body input {
  font-family: var(--mono);
}

.modal-body input:focus,
.modal-body select:focus {
  border-color: var(--jade);
  outline: none;
}

.modal-body select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a39c8a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.modal-hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.8;
}

.modal-hint code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--jade);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
}

/* 授权弹窗：错误提示 */
.auth-error {
  color: var(--clay);
  font-weight: 500;
}

/* 模型未配置提示（警告色） */
.model-chip.unconfigured {
  color: var(--clay);
  border-color: var(--clay);
}

.btn {
  background: var(--paper-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 7px 15px;
  font-size: 13px;
  font-family: var(--kai);
  letter-spacing: 0.1em;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--paper);
  border-color: var(--ink-2);
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--jade);
  border-color: var(--jade);
}

/* ============================================================
   Toast（便笺）
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  background: var(--paper-3);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--jade);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-family: var(--kai);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: min(90vw, 420px);
  box-shadow: 0 10px 30px rgba(40, 37, 30, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-left-color: var(--clay);
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 14px 0 44px rgba(40, 37, 30, 0.3);
    width: min(var(--sidebar-width), 84vw);
    flex-basis: auto;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: grid;
  }

  .task {
    padding: 0 16px 20px;
  }

  .task-steps {
    padding-left: 24px;
  }

  .step-dot {
    left: -23px;
  }

  .ctx-chip {
    display: none;
  }

  .topbar {
    padding: 0 12px;
  }

  .composer-wrap {
    padding: 8px 14px 12px;
  }

  .session-item-preview {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
