:root {
  --jt-bg: #f3f6fb;
  --jt-panel: #ffffff;
  --jt-text: #0a1633;
  --jt-soft: #5c6478;
  --jt-line: #e4e9f2;
  --jt-primary: #00558b;
  --jt-primary-alt: #1c8ad6;
  --jt-accent: #0071e3;
  --jt-ok: #00b894;
  --jt-bad: #e74c3c;
  --jt-user-bubble: #e8f3fc;
  --jt-shadow: 0 18px 40px rgba(0, 85, 139, 0.08);
  --rail: 64px;
  --sidebar: 280px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--jt-bg);
  color: var(--jt-text);
}
.d-none { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--rail) var(--sidebar) 1fr;
  height: 100vh;
  min-height: 560px;
}

.rail {
  background: #0b1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 10px;
}
.rail-logo {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, var(--jt-primary), var(--jt-primary-alt));
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.rail-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: transparent; color: #9fb3c9; cursor: pointer; font-size: 16px;
}
.rail-btn.active, .rail-btn:hover { background: rgba(28, 138, 214, 0.25); color: #fff; }
.rail-spacer { flex: 1; }

.sidebar {
  background: var(--jt-panel);
  border-right: 1px solid var(--jt-line);
  display: flex; flex-direction: column; padding: 16px 14px; gap: 10px;
  min-width: 0;
}
.sidebar-brand { display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 8px; }
.brand-mark { font-weight: 700; font-size: 1.05rem; color: var(--jt-primary); }
.brand-sub { font-size: 0.75rem; color: var(--jt-soft); }
.btn-new {
  border: 0; border-radius: 999px; padding: 12px 14px; cursor: pointer;
  color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--jt-primary), var(--jt-primary-alt));
  box-shadow: 0 10px 24px rgba(0, 85, 139, 0.22);
}
.sidebar-search {
  border: 1px solid var(--jt-line); border-radius: 999px; padding: 10px 14px;
  background: #f7f9fc; outline: none; width: 100%;
}
.history { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.history-item {
  text-align: left; border: 0; background: transparent; border-radius: 12px;
  padding: 10px 12px; cursor: pointer; color: var(--jt-text); font-size: 0.88rem;
}
.history-item:hover { background: #eef5fb; }
.history-item.active { background: #e3f0fb; color: var(--jt-primary); font-weight: 600; }
.history-item .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .d { font-size: 0.72rem; color: var(--jt-soft); margin-top: 2px; }
.sidebar-foot { border-top: 1px solid var(--jt-line); padding-top: 10px; display: grid; gap: 8px; }
.deps { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-size: 0.7rem; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--jt-line); color: var(--jt-soft); background: #fff;
}
.pill.ok { color: var(--jt-ok); border-color: rgba(0,184,148,.35); }
.pill.bad { color: var(--jt-bad); border-color: rgba(231,76,60,.35); }
.linkish {
  border: 0; background: transparent; color: var(--jt-accent); cursor: pointer;
  padding: 0; text-align: left; font-size: 0.85rem;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  background: linear-gradient(180deg, #f8fbff 0%, var(--jt-bg) 28%);
}
.main-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid transparent;
}
.session-title { font-weight: 650; font-size: 1rem; }
.main-meta { font-size: 0.78rem; color: var(--jt-soft); }

.chat { overflow: auto; padding: 8px 28px 18px; }
.welcome {
  max-width: 820px; margin: 48px auto 24px; text-align: center;
}
.welcome-icon { font-size: 42px; margin-bottom: 8px; }
.welcome h1 { font-size: 1.45rem; margin: 0 0 8px; font-weight: 700; }
.welcome > p { color: var(--jt-soft); margin: 0 auto 22px; max-width: 560px; line-height: 1.55; }
.feature-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px;
}
.feature {
  background: var(--jt-panel); border: 1px solid var(--jt-line); border-radius: 16px;
  padding: 14px 12px; text-align: left; box-shadow: var(--jt-shadow);
  display: grid; gap: 4px;
}
.feature strong { font-size: 0.9rem; }
.feature span { font-size: 0.78rem; color: var(--jt-soft); }
.chips-label { font-size: 0.82rem; color: var(--jt-soft); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid #cfe3f5; background: #eef6fc; color: var(--jt-primary);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 0.82rem;
}
.chip:hover { background: #dceffc; }

.messages {
  max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
  padding-bottom: 12px;
}
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.msg.user .avatar { background: #d8efe4; color: #1b7a5a; }
.msg.bot .avatar {
  background: linear-gradient(135deg, var(--jt-primary), var(--jt-primary-alt)); color: #fff;
}
.bubble-wrap { max-width: min(720px, 86%); }
.bubble-meta { font-size: 0.72rem; color: var(--jt-soft); margin-bottom: 4px; }
.msg.user .bubble-meta { text-align: right; }
.bubble {
  background: var(--jt-panel); border: 1px solid var(--jt-line);
  border-radius: 16px; padding: 12px 14px; line-height: 1.55; font-size: 0.92rem;
  box-shadow: 0 8px 20px rgba(10, 22, 51, 0.04);
}
.msg.user .bubble {
  background: var(--jt-user-bubble); border-color: #c9e2f6;
}
.bubble .typing { color: var(--jt-soft); }
.msg-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.msg-chips .chip {
  font-size: 0.78rem; padding: 5px 10px; border-radius: 999px;
  border: 1px solid #b7d4ee; background: #f3f9ff; color: #1a4f7a; cursor: pointer;
}
.msg-chips .chip:hover { background: #dceffc; }
.result-intro { white-space: pre-wrap; }

.result-head {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px; font-size: 0.86rem;
}
.result-head .sum { color: var(--jt-soft); }
.result-list { display: grid; gap: 10px; }
.result-card {
  border: 1px solid var(--jt-line); border-radius: 14px; padding: 12px;
  background: #fbfdff; display: grid; gap: 6px;
}
.result-card .name { font-weight: 650; }
.result-card .stats {
  display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 0.78rem; color: var(--jt-soft);
}
.result-card .reason { font-size: 0.8rem; color: #35506e; }
.result-card .badge {
  display: inline-block; font-size: 0.7rem; padding: 2px 8px; border-radius: 999px;
  background: #e8f6ef; color: #1a8a64; margin-right: 6px;
}

.composer {
  padding: 10px 28px 18px;
}
.composer-box {
  max-width: 860px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end;
  background: var(--jt-panel); border: 1.5px solid #b7d4ee; border-radius: 24px;
  padding: 10px 12px 10px 16px; box-shadow: var(--jt-shadow);
}
.composer-box textarea {
  flex: 1; border: 0; resize: none; outline: none; max-height: 140px;
  font: inherit; line-height: 1.45; background: transparent; padding: 8px 0;
}
.btn-send {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  color: #fff; font-size: 16px;
  background: linear-gradient(135deg, var(--jt-primary), var(--jt-primary-alt));
}
.btn-send:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-hint {
  max-width: 860px; margin: 8px auto 0; font-size: 0.72rem; color: var(--jt-soft); text-align: center;
}

.modal {
  position: fixed; inset: 0; background: rgba(10, 22, 51, 0.45);
  display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal-card {
  width: min(420px, 100%); background: #fff; border-radius: 16px; padding: 20px;
  box-shadow: var(--jt-shadow); display: grid; gap: 8px;
}
.modal-card h2 { margin: 0; font-size: 1.1rem; }
.modal-card .muted { margin: 0 0 6px; color: var(--jt-soft); font-size: 0.85rem; }
.modal-card label { font-size: 0.78rem; color: var(--jt-soft); }
.modal-card input, .modal-card select {
  border: 1px solid var(--jt-line); border-radius: 10px; padding: 10px 12px; font: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.btn-primary {
  border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--jt-primary), var(--jt-primary-alt)); font-weight: 600;
}
.btn-ghost {
  border: 1px solid var(--jt-line); border-radius: 999px; padding: 10px 16px;
  background: #fff; cursor: pointer;
}
.err { color: var(--jt-bad); font-size: 0.82rem; min-height: 1.2em; }

@media (max-width: 960px) {
  .app { grid-template-columns: var(--rail) 1fr; }
  .sidebar { display: none; }
  .feature-row { grid-template-columns: 1fr; }
}
