/* DCKP 小科 */
:root {
  --primary: #2b6cb0;
  --primary-hover: #2c5282;
  --primary-soft: #ebf4ff;
  --bg: #f7fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #f9fafb;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e0;
  --text: #1a202c;
  --text-muted: #718096;
  --text-light: #a0aec0;
  --success: #38a169;
  --error: #e53e3e;
  --warning: #d69e2e;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 16px 48px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); }
body { font-size: 14px; line-height: 1.6; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ============== Auth Page ============== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: #ffffff;
  padding: 0;
  overflow: hidden;
}
.auth-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.74fr) minmax(460px, 1fr);
  background: #ffffff;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}
.auth-visual {
  position: relative;
  min-height: 100vh;
  color: #f3fbff;
  background:
    linear-gradient(90deg, rgba(2, 8, 16, 0.16) 0%, rgba(2, 8, 16, 0.03) 42%, rgba(2, 8, 16, 0.42) 100%),
    linear-gradient(180deg, rgba(2, 8, 16, 0.02) 0%, rgba(2, 8, 16, 0.22) 58%, rgba(2, 8, 16, 0.76) 100%),
    url('/assets/dckp-xiaoke-robot-hero.png') 42% center / cover no-repeat;
}
.auth-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 14, 28, 0.18), rgba(3, 14, 28, 0) 32%, rgba(3, 14, 28, 0.2)),
    radial-gradient(circle at 62% 46%, rgba(38, 137, 255, 0.18), rgba(38, 137, 255, 0) 32%),
    linear-gradient(180deg, rgba(2, 8, 16, 0), rgba(2, 8, 16, 0.36));
  pointer-events: none;
}
.auth-visual-stage {
  position: absolute;
  z-index: 1;
  inset: 0;
  padding: clamp(54px, 7vh, 90px) clamp(42px, 6vw, 84px);
  text-align: center;
}
.auth-visual-status {
  position: absolute;
  top: clamp(42px, 7vh, 78px);
  right: clamp(44px, 6vw, 96px);
  width: min(320px, calc(100% - 88px));
  padding: 18px 18px 16px;
  border: 1px solid rgba(145, 205, 255, 0.25);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(5, 22, 39, 0.58), rgba(5, 22, 39, 0.32));
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(9px);
  text-align: left;
}
.auth-status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 13px;
  margin-bottom: 13px;
  border-bottom: 1px solid rgba(173, 221, 255, 0.18);
}
.auth-status-head span {
  color: rgba(227, 244, 255, 0.88);
  font-size: 15px;
  font-weight: 720;
}
.auth-status-head strong {
  color: #ffffff;
  font-size: 40px;
  line-height: 0.92;
  font-weight: 840;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(35, 220, 190, 0.38);
}
.auth-status-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 18px;
  row-gap: 9px;
  color: rgba(225, 243, 255, 0.88);
  font-size: 13px;
  line-height: 1.25;
}
.auth-status-grid span {
  color: rgba(186, 219, 244, 0.8);
  font-weight: 650;
}
.auth-status-grid strong {
  color: #f5fbff;
  font-weight: 780;
}
.auth-visual-title {
  position: absolute;
  left: 62%;
  top: 47%;
  transform: translate(-50%, -50%);
  width: min(780px, 76%);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
.auth-visual-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 12px;
  border: 1px solid rgba(104, 190, 255, 0.3);
  border-radius: 999px;
  color: #b8e9ff;
  font-size: 12px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: 0;
  background: rgba(5, 20, 36, 0.42);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}
.auth-visual-title h2 {
  margin: 18px 0 14px;
  color: #ffffff;
  font-size: clamp(42px, 4.15vw, 60px);
  line-height: 1.05;
  font-weight: 860;
  letter-spacing: 0;
  white-space: nowrap;
  text-shadow: 0 10px 34px rgba(0, 0, 0, 0.62);
}
.auth-visual-title p {
  margin: 0 auto;
  max-width: 620px;
  color: rgba(235, 247, 255, 0.92);
  font-size: clamp(16px, 1.45vw, 21px);
  line-height: 1.65;
  font-weight: 620;
  text-shadow: 0 8px 26px rgba(0, 0, 0, 0.58);
}
.auth-visual-tags {
  position: absolute;
  left: 50%;
  bottom: clamp(42px, 6vh, 78px);
  transform: translateX(-50%);
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.auth-visual-tags span {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid rgba(183, 222, 255, 0.26);
  border-radius: 10px;
  color: rgba(241, 249, 255, 0.9);
  background: linear-gradient(180deg, rgba(8, 25, 43, 0.58), rgba(8, 25, 43, 0.34));
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 680;
}
.auth-visual-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.auth-card {
  position: relative;
  background:
    radial-gradient(circle at 78% 8%, rgba(23, 104, 217, 0.032), rgba(23, 104, 217, 0) 28%),
    linear-gradient(180deg, #ffffff 0%, #ffffff 58%, #f9fbff 100%),
    #ffffff;
  padding: clamp(52px, 7vh, 76px) clamp(54px, 5.6vw, 88px);
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: none;
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 1px;
  background: linear-gradient(180deg, rgba(18, 99, 216, 0), rgba(18, 99, 216, 0.22), rgba(18, 99, 216, 0));
}
.auth-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0), rgba(23, 104, 217, 0.035));
  mask-image: linear-gradient(135deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0) 64%);
  pointer-events: none;
}
.auth-panel {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  min-height: min(680px, calc(100vh - 104px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.auth-brand {
  text-align: left;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  width: 100%;
  margin-bottom: clamp(52px, 7vh, 68px);
}
.auth-logo {
  display: block;
  width: 164px;
  max-width: 50%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(9, 53, 102, 0.05));
}
.auth-brand-product {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #164267;
  box-shadow: none;
  white-space: nowrap;
}
.auth-brand-product strong {
  color: #111827;
  font-size: 21px;
  line-height: 1;
  font-weight: 760;
  font-style: normal;
  letter-spacing: 0;
  text-align: center;
}
.auth-brand-product span {
  color: #1768d9;
  font-size: 15px;
  line-height: 1;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0;
  text-align: center;
}
.auth-wordmark {
  color: #1263d8;
  font-size: 30px;
  line-height: 1;
  font-weight: 920;
  letter-spacing: 0;
  font-style: italic;
}
.auth-brand-divider {
  width: 1px;
  height: 30px;
  background: #d1d7e2;
}
.auth-brand-name {
  color: #111827;
  font-size: 27px;
  line-height: 1;
  font-weight: 780;
  letter-spacing: 0;
}
.auth-gateway {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
}
.auth-gateway::before {
  display: none;
}
.auth-gateway::after {
  display: none;
}
.auth-form-intro {
  max-width: 420px;
  margin-bottom: 0;
}
.auth-card.is-register .auth-form-intro { margin-bottom: 0; }
.auth-company-line {
  margin: 0;
  color: #838b9a;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}
.auth-form-intro h1 {
  margin: 26px 0 14px;
  font-size: 44px;
  line-height: 1.1;
  color: #070b12;
  font-weight: 760;
  letter-spacing: 0;
  font-style: normal;
  font-family: var(--font);
  transform: none;
}
.auth-form-intro h1 span {
  color: #1768d9;
  font-style: normal;
  font-family: var(--font);
  font-weight: 780;
  letter-spacing: 0;
}
.auth-product-line {
  margin: 10px 0 0;
  max-width: 370px;
  color: #1f2937;
  font-size: 27px;
  line-height: 1.22;
  font-weight: 760;
  letter-spacing: 0;
}
.auth-orbit {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  height: 34px;
  align-items: center;
}
.auth-orbit span {
  position: relative;
  display: block;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(23, 104, 217, 0.22), rgba(29, 180, 155, 0.36));
  overflow: hidden;
}
.auth-orbit span::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 34%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1768d9, #1db49b);
  box-shadow: 0 0 16px rgba(29, 180, 155, 0.28);
}
.auth-orbit span:nth-child(2)::after { left: 38%; }
.auth-orbit span:nth-child(3)::after { left: 64%; width: 26%; }
.auth-signal-board {
  display: grid;
  gap: 9px;
  margin: 0 0 22px;
}
.auth-card.is-register .auth-signal-board { display: none; }
.auth-signal-item {
  position: relative;
  display: grid;
  grid-template-columns: 38px 94px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px 0 0;
  color: #172033;
}
.auth-signal-item::before {
  content: "";
  position: absolute;
  left: -29px;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #1768d9;
  box-shadow: 0 0 0 5px rgba(23, 104, 217, 0.12);
  transform: translateY(-50%);
}
.auth-signal-item:nth-child(2)::before { background: #1db49b; box-shadow: 0 0 0 5px rgba(29, 180, 155, 0.13); }
.auth-signal-item:nth-child(3)::before { background: #63a84f; box-shadow: 0 0 0 5px rgba(99, 168, 79, 0.13); }
.auth-signal-item span {
  color: #1768d9;
  font-size: 11px;
  line-height: 1;
  font-weight: 820;
  letter-spacing: 0.04em;
}
.auth-signal-item strong {
  color: #172033;
  font-size: 14px;
  line-height: 1.1;
  font-weight: 780;
}
.auth-signal-item em {
  color: #7c8798;
  font-size: 12px;
  line-height: 1.1;
  font-style: normal;
  font-weight: 560;
  white-space: nowrap;
}
.auth-login-module {
  position: relative;
  margin-top: clamp(34px, 5vh, 46px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
.auth-login-module::before {
  display: none;
}
.auth-form {
  width: 100%;
  padding-top: 0;
  border-top: 0;
}
.auth-form-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.auth-form-heading h2 {
  margin: 0;
  color: #101828;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 760;
}
.auth-form-heading a,
.auth-muted-link {
  color: #1768d9;
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
}
.auth-form-heading a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(23, 104, 217, 0.18);
  border-radius: 8px;
  background: rgba(245, 249, 255, 0.86);
}
.auth-form-heading a:hover,
.auth-muted-link:hover { text-decoration: underline; }
.auth-field {
  position: relative;
  display: block;
  margin-bottom: 14px;
}
.auth-field input {
  width: 100%;
  height: 54px;
  padding: 0 18px 0 52px;
  margin: 0;
  border: 1px solid #d6deeb;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: #111827;
  font-size: 16px;
  font-weight: 520;
  box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.auth-field input[type="password"] { padding-right: 52px; }
.auth-field input::placeholder { color: #9aa5b8; }
.auth-field input:focus {
  outline: none;
  border-color: #2d75e8;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(45, 117, 232, 0.11), 0 14px 32px rgba(17, 62, 125, 0.08);
}
.auth-input-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  width: 22px;
  height: 22px;
  color: #aab3c4;
  transform: translateY(-50%);
  pointer-events: none;
}
.auth-input-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.auth-password-eye {
  position: absolute;
  right: 17px;
  top: 50%;
  width: 21px;
  height: 21px;
  color: #aab3c4;
  transform: translateY(-50%);
  pointer-events: none;
}
.auth-password-eye svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 24px;
  margin: 0 0 22px;
}
.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #6c7689;
  font-size: 15px;
  user-select: none;
}
.auth-check input {
  width: 18px;
  height: 18px;
  accent-color: #1768d9;
  margin: 0;
}
.auth-form .btn-primary {
  width: 100%;
  height: 56px;
  margin-top: 0;
  border-radius: 8px;
  background: #0d63df;
  border-color: #0d63df;
  color: #ffffff;
  font-size: 17px;
  font-weight: 760;
  letter-spacing: 0;
  box-shadow: 0 14px 30px rgba(13, 99, 223, 0.18);
}
.auth-form .btn-primary:hover {
  background: #0a55c3;
  border-color: #0a55c3;
  box-shadow: 0 16px 34px rgba(13, 99, 223, 0.24);
}
.auth-status { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin: 12px 0 0; min-height: 18px; }
.auth-status.busy { background: var(--primary-soft); color: var(--primary); }
.auth-status.ok { background: #c6f6d5; color: var(--success); }
.auth-status.error { background: #fed7d7; color: var(--error); }
.auth-card-footer {
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid #edf1f7;
  color: #8f99aa;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 540;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.auth-card-footer p { margin: 0; }

@media (max-width: 980px) {
  .auth-page { overflow: auto; }
  .auth-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .auth-visual {
    min-height: 44vh;
    background-position: 38% center;
  }
  .auth-visual-stage {
    padding: 36px 28px;
  }
  .auth-visual-status {
    display: none;
  }
  .auth-visual-title {
    width: min(680px, 92%);
    padding: 22px 24px;
    left: 58%;
  }
  .auth-visual-tags {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
  .auth-visual-tags span {
    min-height: 48px;
    font-size: 13px;
    padding: 8px 10px;
  }
  .auth-card { padding: 40px 32px 38px; }
  .auth-panel { min-height: auto; }
  .auth-brand { margin-bottom: 42px; }
  .auth-form-intro { margin-bottom: 0; }
  .auth-login-module { margin-top: 34px; }
  .auth-card-footer { padding-top: 28px; }
}

@media (min-width: 981px) and (max-width: 1280px) {
  .auth-visual {
    background-position: center center;
  }
  .auth-visual-title {
    width: min(560px, 86%);
  }
  .auth-visual-tags {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(580px, 90%);
  }
}

@media (max-width: 640px) {
  .auth-page { padding: 0; background: #ffffff; overflow: auto; }
  .auth-shell {
    width: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .auth-visual {
    min-height: 260px;
    background-position: 34% center;
  }
  .auth-visual-stage {
    padding: 28px 22px 24px;
  }
  .auth-visual-title {
    width: calc(100% - 36px);
    left: 50%;
    top: 50%;
    padding: 0 8px;
    border-radius: 12px;
  }
  .auth-visual-kicker {
    font-size: 10px;
    letter-spacing: 1.2px;
  }
  .auth-visual-title h2 {
    margin-top: 12px;
    font-size: 33px;
  }
  .auth-visual-title p {
    font-size: 13px;
    line-height: 1.55;
  }
  .auth-visual-tags {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    bottom: 20px;
    width: calc(100% - 44px);
  }
  .auth-visual-tags span {
    min-height: 42px;
    font-size: 12px;
    padding: 7px 9px;
  }
  .auth-card { padding: 24px 22px 30px; }
  .auth-brand {
    gap: 13px;
    margin-bottom: 34px;
  }
  .auth-logo {
    width: 140px;
    max-width: 48%;
  }
  .auth-brand-product {
    min-width: 0;
    min-height: 38px;
    gap: 7px;
    padding: 0;
  }
  .auth-brand-product strong { font-size: 17px; }
  .auth-brand-product span { font-size: 12px; }
  .auth-wordmark { font-size: 25px; }
  .auth-brand-name { font-size: 23px; }
  .auth-brand-divider { height: 22px; }
  .auth-gateway {
    margin-bottom: 0;
    padding: 0;
  }
  .auth-gateway::before,
  .auth-gateway::after {
    display: none;
  }
  .auth-form-intro { margin-bottom: 0; }
  .auth-company-line {
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
  }
  .auth-form-intro h1 { margin: 20px 0 10px; font-size: 33px; line-height: 1.12; }
  .auth-product-line {
    margin-top: 8px;
    font-size: 22px;
    line-height: 1.25;
  }
  .auth-orbit { height: 24px; gap: 8px; }
  .auth-orbit span { height: 4px; }
  .auth-signal-board { display: none; }
  .auth-login-module { margin-top: 28px; padding: 0; }
  .auth-form-heading { margin-bottom: 16px; }
  .auth-form-heading h2 { font-size: 23px; }
  .auth-field { margin-bottom: 12px; }
  .auth-field input { height: 52px; font-size: 15px; }
  .auth-options { margin-bottom: 22px; }
  .auth-form .btn-primary { height: 54px; font-size: 17px; }
  .auth-card-footer {
    padding-top: 30px;
    font-size: 12px;
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

/* ============== Buttons ============== */
.btn {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text); font-size: 14px; transition: all 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ============== App Layout ============== */
.app-page { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 280px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  padding: 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.logo-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #d8e4f2;
  box-shadow: 0 8px 22px rgba(15, 59, 112, 0.06);
  overflow: hidden;
}
.logo-icon img {
  display: block;
  width: 24px;
  max-height: 24px;
  object-fit: contain;
}
.logo-text { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sidebar-section-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.section-action-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.section-action-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.tenant-select { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); }
.agent-list, .session-list { display: flex; flex-direction: column; gap: 2px; }
.agent-item, .session-item {
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: background 0.1s;
  font-size: 13px; color: var(--text);
}
.agent-item:hover, .session-item:hover { background: var(--bg-hover); }
.agent-item.active, .session-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.agent-avatar { font-size: 16px; }
.session-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-time { font-size: 11px; color: var(--text-light); }
.session-delete-btn {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.session-item:hover .session-delete-btn,
.session-delete-btn:focus-visible {
  opacity: 1;
}
.session-delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}
.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-muted); }

/* ============== Main Area ============== */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-card); }
.main-header {
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: var(--bg-card);
}
.main-title { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; }
.kb-tag { font-size: 12px; color: var(--text-muted); padding: 2px 8px; background: var(--primary-soft); border-radius: var(--radius-sm); }
.main-actions { display: flex; gap: 8px; }
.main-body { flex: 1; display: flex; min-height: 0; position: relative; }

/* ============== Chat ============== */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.message { display: flex; gap: 12px; max-width: 800px; width: 100%; margin: 0 auto; }
.message.user { flex-direction: row-reverse; }
.message-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0; overflow: hidden;
}
.message.user .message-avatar {
  background: linear-gradient(135deg, #2b6cb0, #1f5a96);
  color: #fff;
  font-weight: 760;
  box-shadow: 0 8px 18px rgba(43, 108, 176, 0.18);
}
.message.assistant .message-avatar {
  width: 36px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #d8e4f2;
  box-shadow: 0 8px 22px rgba(15, 59, 112, 0.08);
}
.message-avatar img {
  display: block;
  width: 24px;
  max-height: 24px;
  object-fit: contain;
}
.message-avatar-initial { line-height: 1; }
.message-body { padding: 10px 16px; border-radius: var(--radius-lg); max-width: calc(100% - 60px); }
.message.user .message-body { background: var(--primary); color: #fff; }
.message.assistant .message-body { background: var(--bg-hover); }
.message-author {
  margin-bottom: 6px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 700;
}
.message.user .message-author {
  color: rgba(255, 255, 255, 0.86);
  text-align: right;
}
.message.assistant .message-author {
  color: #1768d9;
}
.message-content { word-break: break-word; overflow-x: auto; }
.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre { background: #1a202c; color: #e2e8f0; padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px; }
.message-content code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 3px; font-size: 12px; }
.message.user .message-content code { background: rgba(255,255,255,0.2); }
.message-content blockquote { border-left: 3px solid var(--border-strong); padding-left: 12px; color: var(--text-muted); margin: 8px 0; }
.citations { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong); font-size: 12px; color: var(--text-muted); }
.citation-item { padding: 2px 0; }
.chat-input-area { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg-card); }
.chat-input-wrap { display: flex; gap: 8px; align-items: flex-end; max-width: 800px; margin: 0 auto; }
#chat-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); resize: vertical; min-height: 44px; max-height: 60vh;
  line-height: 1.5; scrollbar-width: thin;
}
#chat-input:focus { outline: none; border-color: var(--primary); }
.typing-indicator { padding: 0 0 8px 0; color: var(--text-muted); font-size: 12px; display: flex; gap: 4px; align-items: center; max-width: 800px; margin: 0 auto; }

/* === 文件预览条 (输入框上方) === */
.attach-previews { max-width: 800px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.attach-previews:empty { display: none; }
.attach-previews-header { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 4px; font-size: 12px; color: var(--text-muted); }
.attach-previews-list { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.attach-item { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px; background: var(--bg-hover); border-radius: var(--radius-sm); border: 1px solid var(--border); max-width: 240px; position: relative; }
.attach-item-img .attach-thumb { width: 36px; height: 36px; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.attach-item-img .attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-item-doc .attach-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
.attach-meta { flex:1; min-width: 0; }
.attach-name { font-size: 11px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-sub { font-size: 10px; color: var(--text-muted); }
.attach-preview { font-size: 10px; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.attach-remove { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%; border: none; background: rgba(0,0,0,0.2); color: #fff; font-size: 10px; line-height: 16px; text-align: center; cursor: pointer; padding: 0; }
.attach-clear-all { font-size: 11px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border); background: transparent; cursor: pointer; color: var(--text-muted); }

.typing-indicator span {
  display: inline-block; width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ============== Side Panels ============== */
.side-panel { width: 360px; border-left: 1px solid var(--border); background: var(--bg-card); display: flex; flex-direction: column; }
.panel-header { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.panel-header h3 { margin: 0; font-size: 15px; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px; }
.kb-list, .agent-detail-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.kb-card, .agent-card {
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  transition: all 0.15s; background: var(--bg-card);
}
.kb-card:hover, .agent-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.kb-card.active, .agent-card.active { border-color: var(--primary); background: var(--primary-soft); }
.kb-card-title, .agent-card-title { font-weight: 500; margin-bottom: 4px; }
.kb-card-meta, .agent-card-meta { font-size: 12px; color: var(--text-muted); }
.kb-detail { margin-top: 12px; }
.kb-detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kb-actions { margin-bottom: 12px; }
.knowledge-list { display: flex; flex-direction: column; gap: 6px; }
.knowledge-item { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.knowledge-item:hover { background: var(--bg-hover); }
.knowledge-item-title { font-weight: 500; font-size: 13px; }
.knowledge-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============== Modal ============== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-card-compact { max-width: 420px; }
.modal-card-wide { max-width: 720px; }
.modal-card h3 { margin: 0 0 16px 0; }
.modal-help {
  margin: -6px 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}
.modal-card input, .modal-card textarea, .modal-card select {
  width: 100%; padding: 8px 12px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card);
}
.modal-card input:focus, .modal-card textarea:focus, .modal-card select:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ============== Toast ============== */
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius);
  background: var(--text); color: #fff; box-shadow: var(--shadow-lg); z-index: 2000;
  animation: slideIn 0.2s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============== Empty states ============== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); padding: 40px; text-align: center;
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.empty-state-desc { font-size: 13px; max-width: 400px; }
.welcome-card {
  max-width: 600px; margin: 60px auto; padding: 32px; text-align: center;
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.welcome-card h2 { margin: 0 0 12px 0; color: var(--primary); }
.welcome-card p { color: var(--text-muted); }
.welcome-card .feature-list { text-align: left; margin: 24px 0; }
.welcome-card .feature-list li { padding: 4px 0; color: var(--text); }


/* ============== Document Viewer ============== */
.doc-view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.doc-view-header h3 { margin: 0; }
.doc-view-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; display: flex; gap: 12px; flex-wrap: wrap; }
.doc-view-meta .tag { padding: 2px 8px; background: var(--primary-soft); color: var(--primary); border-radius: var(--radius-sm); font-size: 11px; }
.doc-view-content {
  padding: 16px; background: var(--bg); border-radius: var(--radius);
  max-height: 60vh; overflow-y: auto; line-height: 1.7;
}
.doc-view-content h1, .doc-view-content h2, .doc-view-content h3 { margin-top: 16px; }
.doc-view-content h1 { font-size: 20px; }
.doc-view-content h2 { font-size: 17px; }
.doc-view-content h3 { font-size: 14px; }
.doc-view-content pre { background: #1a202c; color: #e2e8f0; padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px; }
.doc-view-content code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 3px; font-size: 12px; }
.doc-view-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.doc-view-content th, .doc-view-content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.doc-view-content th { background: var(--bg-hover); font-weight: 600; }
.doc-view-content blockquote { border-left: 3px solid var(--border-strong); padding-left: 12px; color: var(--text-muted); margin: 12px 0; }
.doc-view-content ul, .doc-view-content ol { padding-left: 24px; }

/* ============== Theme Toggle ============== */
.theme-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 999;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; box-shadow: var(--shadow);
  transition: all 0.15s;
}
.theme-toggle:hover { transform: scale(1.1); }

/* ============== Dark Theme ============== */
body.dark {
  --bg: #0f1419;
  --bg-card: #1a2028;
  --bg-sidebar: #131820;
  --bg-hover: #232a35;
  --border: #2a3340;
  --border-strong: #3a4452;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --primary-soft: #1e3a5f;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4), 0 16px 48px rgba(0,0,0,0.3);
}
body.dark .doc-view-content pre { background: #0a0e13; }
body.dark .doc-view-content code { background: rgba(255,255,255,0.08); }
body.dark .doc-view-content th { background: var(--bg-hover); }
body.dark .message.user .message-body { background: var(--primary); }
body.dark .message.assistant .message-body { background: var(--bg-hover); }
body.dark .message.assistant .message-avatar { background: #f8fbff; border-color: #31445f; }
body.dark .logo-icon { background: #f8fbff; border-color: #31445f; }
body.dark .message-author { color: #94a3b8; }
body.dark .message.assistant .message-author { color: #77aef7; }
body.dark .message.user .message-content code { background: rgba(255,255,255,0.2); }
body.dark .modal-card input, body.dark .modal-card textarea, body.dark .modal-card select { background: var(--bg); }

/* ============== Search Highlight ============== */
mark.search-highlight {
  background: #fef08a; color: #1a202c; padding: 0 2px; border-radius: 2px;
}
body.dark mark.search-highlight { background: #fbbf24; color: #0f1419; }

/* ============== Empty / Loading ============== */
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 知识库文件上传状态条 */
.kb-upload-status {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  margin-bottom: 8px;
  min-height: 0;
  transition: all 0.2s;
}
.kb-upload-status:empty { display: none; }
.kb-upload-status.busy {
  background: rgba(59, 130, 246, 0.12);
  color: #1e40af;
  border-left: 3px solid #3b82f6;
  position: relative;
  overflow: hidden;
  white-space: pre-line;
}
.kb-upload-status.ok {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
  border-left: 3px solid #22c55e;
}
.kb-upload-status.error {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
  border-left: 3px solid #ef4444;
}

.kb-upload-status.busy::after {
  content: "";
  display: block;
  height: 3px;
  margin-top: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  animation: kbUploadProgressPulse 1.2s ease-in-out infinite;
}

/* 聊天附件预览条 */
.attach-previews {
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  max-width: 100%;
  flex-wrap: nowrap;
}
.attach-previews:empty { display: none; }
.attach-thumb {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border, #e5e7eb);
}
.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.attach-remove:hover {
  background: rgba(239, 68, 68, 0.9);
}

/* 聊天附件: 文档缩略图 */
.attach-doc {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-2, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 12px;
  max-width: 180px;
  flex-shrink: 0;
  position: relative;
}
.attach-doc-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.attach-doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.attach-doc .attach-remove {
  position: static;
  background: transparent;
  color: var(--text-2, #666);
  font-size: 14px;
  width: 16px;
  height: 16px;
}
.attach-doc .attach-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* 即将发送附件预览条 */
.attach-previews {
  margin: 8px 12px 4px 12px;
  background: var(--bg-1, #f8fafc);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}
.attach-previews-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.08);
  border-bottom: 1px solid var(--border, #e5e7eb);
  font-size: 12px;
  font-weight: 600;
  color: #1e40af;
  position: sticky;
  top: 0;
}
.attach-previews-title {
  font-weight: 600;
}
.attach-clear-all {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.attach-clear-all:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.attach-previews-list {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-2, white);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  position: relative;
}
.attach-item-img .attach-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.attach-item-img .attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attach-item-doc .attach-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}
.attach-meta {
  flex: 1;
  min-width: 0;
}
.attach-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-sub {
  font-size: 11px;
  color: var(--text-2, #6b7280);
  margin-top: 1px;
}
.attach-preview {
  font-size: 11px;
  color: var(--text-2, #6b7280);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}
.attach-remove {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  flex-shrink: 0;
}
.attach-remove:hover {
  color: #ef4444;
}

/* 用户消息里的附件清单 */
.user-attach-list {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.3));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-attach-item {
  font-size: 12px;
  opacity: 0.9;
}
.user-text {
  white-space: pre-wrap;
}

/* file input 隐藏在 label 里, label 本身就是按钮, 用户点 label 就触发 file 选择 */
/* 聊天输入框: 可拖动高度 + 不丢内容 */
#chat-input {
  resize: vertical;
  min-height: 38px;
  max-height: 400px;  /* 拉到 400 就不再长了, 自动滚动 */
  overflow-y: auto;
  /* 关键: 不要 height: auto, 让用户拉多高就是多高, 切走再回来不丢 */
}


/* Citations 引用样式 (agent 知识图谱溯源) */
.citations {
  margin-top: 10px;
  padding: 8px 10px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 3px solid #3b82f6;
  border-radius: 6px;
  font-size: 12px;
}
.citations-title {
  font-weight: 600;
  color: #1e40af;
  margin-bottom: 6px;
  font-size: 11px;
}
.citation-item {
  color: #475569;
  padding: 3px 0;
  border-bottom: 1px dashed #cbd5e1;
  transition: all 0.15s;
}
.citation-item:last-child { border-bottom: none; }
.citation-item:hover {
  background: #ffffff;
  color: #1e40af;
  transform: translateX(2px);
}
.citation-atom {
  color: #7c3aed;
  font-style: italic;
  font-weight: 500;
}
.citation-oid {
  color: #94a3b8;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  margin-left: 4px;
}

/* === 侧栏项目(KB)列表 === */
.project-kb-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; }
.project-kb-group { padding-bottom: 4px; }
.project-kb-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text);
  transition: background 0.12s;
}
.project-kb-item:hover { background: var(--bg-hover); }
.project-kb-item.active { background: var(--primary-bg, #eef2ff); color: var(--primary, #4338ca); font-weight: 500; }
.project-kb-icon { font-size: 14px; flex-shrink: 0; }
.project-kb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-edit-btn,
.project-delete-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.project-kb-item:hover .project-edit-btn,
.project-kb-item:hover .project-delete-btn,
.project-edit-btn:focus-visible,
.project-delete-btn:focus-visible {
  opacity: 1;
}
.project-edit-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.project-delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}
.project-kb-empty { color: var(--text-light); font-size: 12px; padding: 8px 10px; }
.project-session-list { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 18px; }
.project-session-item { padding: 5px 8px; font-size: 12px; color: var(--text-muted); }
.project-session-item.active { color: var(--primary); }
.project-session-empty { color: var(--text-light); font-size: 11px; padding: 4px 8px; }


/* === 成熟聊天界面升级 === */

/* 消息容器 - 更高级的气泡效果 */
.messages {
  scroll-behavior: smooth;
}

/* 消息气泡 - 更圆润, 有阴影和过渡 */
.message {
  animation: messageSlideIn 0.25s ease-out;
}

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

.message-body {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}

.message-body:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.message.user .message-body {
  border-bottom-right-radius: 4px;
}

.message.assistant .message-body {
  border-bottom-left-radius: 4px;
}

/* 用户消息里的附件标签更美观 */
.user-attach-list {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.25);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.user-attach-item {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 10px;
}

/* 拖放高亮覆盖层 */
.chat-input-area.drag-over {
  position: relative;
  background: var(--primary-bg, #eef2ff) !important;
  transition: background 0.2s;
}

.chat-input-area.drag-over::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed var(--primary, #4338ca);
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 10;
}

.drop-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  padding: 12px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-size: 16px;
  font-weight: 500;
  z-index: 20;
  pointer-events: none;
  animation: dropHintPulse 1.5s ease-in-out infinite;
}

@keyframes dropHintPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.05); opacity: 0.8; }
}

/* 附件预览 - 更紧凑整齐 */
.attach-previews {
  max-width: 800px;
  margin: 0 auto 4px;
}

.attach-previews-header {
  padding: 0 4px;
  margin-bottom: 4px;
}

.attach-previews-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.attach-item {
  max-width: 220px;
  padding: 4px 6px;
  gap: 4px;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.attach-item:hover {
  background: var(--bg-card);
  border-color: var(--primary, #4338ca);
}

.attach-item-uploading {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.06);
}

.attach-item-uploading:hover {
  border-color: rgba(37, 99, 235, 0.7);
  background: rgba(37, 99, 235, 0.08);
}

.attach-item-failed {
  border-color: rgba(239, 68, 68, 0.48);
  background: rgba(239, 68, 68, 0.07);
}

.attach-item-img .attach-thumb {
  width: 32px;
  height: 32px;
}

.attach-item-doc .attach-icon {
  font-size: 18px;
  line-height: 32px;
  width: 32px;
  text-align: center;
}

.attach-name {
  font-size: 11px;
  line-height: 1.3;
}

.attach-sub {
  font-size: 9px;
  line-height: 1.2;
}

.attach-item-uploading .attach-sub {
  color: #1d4ed8;
  font-weight: 650;
}

.attach-item-failed .attach-sub,
.attach-item-failed .attach-preview {
  color: #b91c1c;
}

.attach-preview {
  font-size: 9px;
  margin-top: 1px;
}

.attach-upload-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: #2563eb;
  border-radius: 999px;
  vertical-align: middle;
  animation: attachSpin 0.8s linear infinite;
}

.attach-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.attach-progress-bar {
  flex: 1;
  position: relative;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.16);
}

.attach-progress-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  min-width: 3px;
  max-width: 100%;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  transition: width 0.18s ease;
}

.attach-progress-percent {
  min-width: 32px;
  font-size: 9px;
  line-height: 1;
  color: #1d4ed8;
  text-align: right;
  font-weight: 750;
}

@keyframes attachSpin {
  to { transform: rotate(360deg); }
}

@keyframes attachProgress {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(250%); }
}

@keyframes kbUploadProgressPulse {
  0%, 100% { opacity: 0.55; transform: scaleX(0.9); transform-origin: left center; }
  50% { opacity: 1; transform: scaleX(1); transform-origin: left center; }
}

.attach-remove {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  font-size: 8px;
  line-height: 14px;
  background: rgba(0,0,0,0.15);
  opacity: 0;
  transition: opacity 0.15s;
}

.attach-item:hover .attach-remove {
  opacity: 1;
}

/* ============== Task Center ============== */
.modal-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.task-center-header {
  align-items: flex-start;
  gap: 16px;
}

.task-center-title {
  min-width: 0;
}

.task-center-title h3 {
  margin-bottom: 0;
}

.task-center-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.task-center-actions .btn {
  white-space: nowrap;
  word-break: keep-all;
}

.task-center-list {
  display: grid;
  gap: 10px;
  max-height: min(68vh, 620px);
  overflow: auto;
  padding: 4px 2px 2px;
}

.task-empty {
  padding: 28px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-hover);
}

.task-diagnostics-panel {
  margin: 0 2px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
}

.task-logs-panel {
  margin: 0 2px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
}

.task-log-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.task-log-title strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.task-log-title span,
.task-log-path {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
  word-break: break-all;
}

.task-log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.task-log-block {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: hidden;
}

.task-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.task-log-head strong {
  color: var(--text);
  font-size: 12px;
}

.task-log-head span {
  color: var(--text-muted);
  font-size: 11px;
}

.task-log-path {
  padding: 7px 10px 0;
}

.task-log-tail {
  max-height: 220px;
  margin: 8px 10px 10px;
  padding: 10px;
  overflow: auto;
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.task-log-events {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: hidden;
}

.task-log-events li {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.task-log-events li:first-child {
  border-top: 0;
}

.task-log-events strong {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.task-log-events span {
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.goal-audit-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.goal-audit-head,
.goal-audit-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.goal-audit-head strong,
.goal-audit-section-head strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.goal-audit-head span {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.goal-audit-blockers {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  background: #fff7f7;
}

.goal-audit-blocker-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.goal-audit-blocker-title strong {
  color: #991b1b;
  font-size: 13px;
}

.goal-audit-blocker-title span {
  color: #991b1b;
  font-size: 11px;
  font-weight: 600;
}

.goal-audit-blockers ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.goal-audit-blockers li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  padding-top: 8px;
  border-top: 1px solid #fee2e2;
}

.goal-audit-blockers li:first-child {
  padding-top: 0;
  border-top: 0;
}

.goal-audit-blockers li strong,
.goal-audit-blockers li span,
.goal-audit-blockers li small {
  display: block;
}

.goal-audit-blockers li strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.goal-audit-blockers li span,
.goal-audit-blockers li small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.goal-audit-blockers li small {
  grid-column: 1 / -1;
}

.goal-audit-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.goal-audit-section {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.goal-audit-section ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.goal-audit-section li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.goal-audit-section li small {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.goal-audit-status {
  white-space: nowrap;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-hover);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

.goal-audit-achieved {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.goal-audit-partial,
.goal-audit-unverified {
  color: #92400e;
  border-color: #fde68a;
  background: #fffbeb;
}

.goal-audit-missing {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.task-diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.task-diagnostic-grid > div {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.task-diagnostic-grid span,
.task-diagnostic-row span,
.task-diagnostic-columns span {
  color: var(--text-muted);
  font-size: 12px;
}

.task-diagnostic-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 15px;
}

.task-diagnostic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.task-diagnostic-row span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.task-diagnostic-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.task-diagnostic-columns ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: hidden;
}

.task-diagnostic-columns li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.task-diagnostic-columns li:first-child {
  border-top: 0;
}

.task-diagnostic-columns strong {
  color: var(--text);
  font-size: 12px;
}

.task-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.task-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.task-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.task-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.task-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #eef2ff;
  color: #3730a3;
}

.task-message {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.task-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.task-progress-row strong {
  min-width: 82px;
  color: var(--text);
  font-size: 12px;
  text-align: right;
}

.task-progress-bar {
  position: relative;
  flex: 1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
}

.task-progress-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 4px;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #16a34a);
  transition: width 0.2s ease;
}

.task-error {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
}

.task-failed-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.task-failed-pages > span {
  color: var(--text-muted);
  font-size: 12px;
}

.task-page-chip {
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff7f7;
  color: #b91c1c;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

.task-page-chip:hover {
  border-color: #ef4444;
  background: #fee2e2;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.task-events-wrap {
  margin-top: 12px;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
}

.task-events {
  display: grid;
  gap: 0;
}

.task-events-empty {
  padding: 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  background: var(--bg-hover);
}

.task-event {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
}

.task-event + .task-event {
  border-top: 1px solid var(--border);
}

.task-event-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: #94a3b8;
}

.task-event.task-status-running .task-event-dot {
  background: #2563eb;
}

.task-event.task-status-done .task-event-dot {
  background: #16a34a;
}

.task-event.task-status-failed .task-event-dot {
  background: #dc2626;
}

.task-event-body {
  min-width: 0;
}

.task-event-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.task-event-line strong {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.task-event-line time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.task-event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.task-event-meta span {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-hover);
}

.task-event-error {
  margin-top: 6px;
  color: #b91c1c;
  font-size: 11px;
  line-height: 1.45;
}

.task-status-running .task-badge,
.task-badge.task-status-running {
  background: #dbeafe;
  color: #1d4ed8;
}

.task-status-queued .task-badge,
.task-badge.task-status-queued {
  background: #fef3c7;
  color: #92400e;
}

.task-status-done .task-badge,
.task-badge.task-status-done {
  background: #dcfce7;
  color: #166534;
}

.task-status-failed .task-badge,
.task-badge.task-status-failed {
  background: #fee2e2;
  color: #b91c1c;
}

@media (max-width: 720px) {
  .task-center-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .task-center-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .task-center-actions .btn {
    min-height: 38px;
    padding-inline: 10px;
  }

  .task-center-actions #task-center-close {
    margin-left: auto;
  }

  .task-diagnostic-grid,
  .task-diagnostic-columns,
  .task-log-grid {
    grid-template-columns: 1fr;
  }

  .task-log-events li {
    grid-template-columns: 1fr;
  }
}

/* 聊天输入区 - 分割线更清晰 */
.chat-input-area {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  position: relative;
}

.chat-input-wrap {
  gap: 8px;
}

/* attach 按钮微调 */
#attach-btn {
  width: 34px;
  height: 34px;
  font-size: 18px;
  border-radius: 8px;
  transition: background 0.12s;
}

#attach-btn:hover {
  background: var(--bg-hover);
}

/* typing indicator 位置微调 */
.typing-indicator {
  padding: 0 0 6px;
  font-size: 12px;
  gap: 4px;
}

/* 发送按钮 */
#send-btn {
  height: 34px;
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
}

#send-btn:active {
  transform: scale(0.96);
}

/* 代码块在消息中更美观 */
.message-content pre {
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  line-height: 1.5;
}

.message-content pre::before {
  content: 'code';
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 8px;
  font-size: 10px;
  color: #94a3b8;
  background: rgba(255,255,255,0.06);
  border-radius: 0 4px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 引用块 */
.message-content blockquote {
  padding: 6px 12px;
  font-style: italic;
  background: rgba(0,0,0,0.02);
}

/* 列表在消息中 */
.message-content ul, .message-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.message-content li {
  margin: 2px 0;
}

/* 表格 */
.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12px;
}

.message-content th, .message-content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.message-content th {
  background: var(--bg-hover);
  font-weight: 600;
}

/* citation 样式 - 更精致 */
.citations {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
}

.citation-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  cursor: default;
}

.citation-item:last-child {
  border-bottom: none;
}

.citation-atom {
  font-size: 11px;
}

.citation-oid {
  font-size: 9px;
}
