:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-weak: #eff4ff;
  --green: #16a34a;
  --grey: #9ca3af;
  --red: #dc2626;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fbfcfe; color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--accent); background: #fff; }
.login-card button {
  width: 100%; padding: 11px; border: 0; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 15px; cursor: pointer; font-weight: 600;
}
.login-card button:hover { background: #1d4ed8; }
.login-card .msg { color: var(--red); font-size: 12px; min-height: 16px; margin: 10px 0 0; }
.login-card .hint { color: var(--muted); font-size: 11px; margin: 12px 0 0; line-height: 1.5; }

/* 主界面 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 2px; }
.dot.grey { background: var(--grey); }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12px; padding: 2px 6px; }
.link-btn:hover { text-decoration: underline; }

.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); height: calc(100vh - 53px); }
.col { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }

/* 对话 */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 10px 13px; border-radius: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-start; background: var(--accent-weak); border-bottom-left-radius: 3px; }
.msg.think { color: var(--muted); font-style: italic; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.composer textarea {
  flex: 1; resize: none; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: #fbfcfe;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer button { padding: 0 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.composer button:disabled { opacity: .5; cursor: default; }

/* 文件 */
.files-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.breadcrumb { padding: 8px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); word-break: break-all; }
.filelist { flex: 1; overflow-y: auto; padding: 8px; }
.entry { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.entry:hover { background: var(--accent-weak); }
.entry .name { display: flex; align-items: center; gap: 8px; }
.entry .ico { width: 18px; text-align: center; }
.entry .meta { font-size: 11px; color: var(--muted); }
.entry .acts { display: flex; gap: 6px; opacity: 0; }
.entry:hover .acts { opacity: 1; }

.fileview { position: absolute; inset: 53px 0 0 50%; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.fileview-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.fileview pre { flex: 1; overflow: auto; margin: 0; padding: 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .fileview { inset: 53px 0 0 0; }
}
