/* claude-web 深色聊天界面 */
:root {
  --bg: #0f1216;
  --panel: #151a21;
  --panel-2: #1c232d;
  --border: #2a3340;
  --text: #dde3ea;
  --text-dim: #8a94a3;
  --accent: #4f8cff;
  --accent-dim: #2c5cbd;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ── 视图 ── */
.view { height: 100%; }
#view-main { display: flex; }

/* ── 登录 ── */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { font-size: 22px; text-align: center; }
.login-card .sub { color: var(--text-dim); text-align: center; margin-bottom: 8px; }
.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.error-text { color: var(--red); min-height: 18px; text-align: center; }

/* ── 按钮 ── */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #6b9fff; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-outline { background: transparent; border-color: var(--red); color: var(--red); }
.btn.danger-outline:hover { background: rgba(248, 81, 73, 0.1); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* ── 侧栏 ── */
#sidebar {
  width: 280px;
  min-width: 280px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-head h1 { font-size: 16px; }

.new-session-box {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.new-session-box label { color: var(--text-dim); font-size: 12px; }
.new-session-box select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
  color: var(--text-dim);
  font-size: 12px;
}
#session-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.session-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
}
.session-item:hover { background: var(--panel-2); }
.session-item.active { background: var(--panel-2); border: 1px solid var(--accent-dim); }
.session-item .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .m { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.session-item .m span + span { margin-left: 8px; }

/* ── 主区 ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── 消息 ── */
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  word-break: break-word;
  line-height: 1.55;
}
.msg.user .bubble { background: var(--accent-dim); color: #fff; }
.msg.assistant .bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  width: 100%;
}

.block { margin: 6px 0; }
.text-block { white-space: pre-wrap; }
.thinking-block {
  color: var(--text-dim);
  font-size: 13px;
  border-left: 2px solid var(--border);
  padding-left: 10px;
  margin: 8px 0;
}
.thinking-block summary { cursor: pointer; user-select: none; }
.thinking-body {
  margin-top: 6px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
  max-height: 240px;
  overflow-y: auto;
}

/* ── 工具卡片 ── */
.tool-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 8px;
  margin: 8px 0;
  background: var(--panel-2);
  font-size: 13px;
}
.tool-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.tool-name { color: var(--orange); font-weight: 600; }
.tool-cmd, .tool-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.tool-details { border-top: 1px solid var(--border); }
.tool-details summary {
  cursor: pointer;
  color: var(--text-dim);
  padding: 6px 12px;
  user-select: none;
}
.tool-input {
  font-family: var(--mono);
  font-size: 12px;
  padding: 0 12px 10px;
  overflow-x: auto;
  color: var(--text-dim);
}
.tool-result {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  color: var(--text-dim);
}
.tool-result.is-error { color: var(--red); }

/* ── 系统消息 ── */
.sysmsg {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  align-self: center;
}
.sysmsg.error { color: var(--red); }
.sysmsg.stderr {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  align-self: flex-start;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
}
.turn-meta {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: -6px;
  align-self: center;
}

/* ── 输入区 ── */
#composer {
  border-top: 1px solid var(--border);
  padding: 14px 24px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--panel);
}
#composer textarea {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 200px;
}
#composer textarea:focus { outline: none; border-color: var(--accent); }
.composer-actions { display: flex; flex-direction: column; gap: 6px; }

#reconnect-bar {
  background: var(--orange);
  color: #000;
  text-align: center;
  padding: 6px;
  font-size: 13px;
}

/* ── 审批模态 ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(560px, 92vw);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 12px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
#modal-title { font-size: 16px; font-weight: 600; }
.badge {
  background: var(--accent-dim);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
}
#modal-desc { color: var(--text-dim); }
#modal-input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: auto;
  max-height: 240px;
  white-space: pre-wrap;
  word-break: break-all;
}
#modal-questions { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.modal-q { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.modal-q .qh { font-weight: 600; margin-bottom: 6px; }
.modal-q .opt { display: block; padding: 4px 0; cursor: pointer; }
.modal-q .opt input { margin-right: 8px; }

#modal-countdown {
  height: 4px;
  background: var(--panel-2);
  border-radius: 2px;
  overflow: hidden;
}
#modal-countdown-bar {
  height: 100%;
  width: 100%;
  background: var(--orange);
  transition: width 1s linear;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
