:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fbfc;
  --line: #dbe5ea;
  --line-strong: #c8d7de;
  --text: #162640;
  --muted: #6c7b90;
  --brand: #1d9eaa;
  --brand-deep: #0f6172;
  --brand-soft: #e7f5f5;
  --danger: #ff334c;
  --shadow: 0 18px 42px rgba(40, 60, 82, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(110deg, rgba(29, 158, 170, 0.07), transparent 34%),
    linear-gradient(140deg, #f7f8fb 0%, #f4efe7 100%);
  overflow-x: hidden;
  height: 100vh;
  overflow: hidden;
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  height: 100vh;
}

/* 左侧菜单固定 */
.sidebar {
  width: 218px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  padding: 22px 0 24px;
  background: rgba(255, 255, 255, 0.84);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 99;
}

.brand-block {
  width: 184px;
  height: 150px;
  border: 0;
  border-radius: 20px 20px 0 0;
  display: grid;
  place-items: center;
  background: #fff;
  overflow: hidden;
}

.brand-logo {
  width: 150px;
  height: auto;
  object-fit: contain;
  display: block;
}

.ai-entry {
  width: 184px;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 16px;
  box-shadow: none;
  transition: 0.18s ease;
  font-size: 16px;
  font-weight: 700;
}

.ai-entry::before {
  content: "AI";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #c9ced8;
  color: #1a2d49;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}

.ai-entry span {
  white-space: nowrap;
}

.ai-entry strong {
  padding: 6px 12px;
  border-radius: 2px;
  background: #ff0022;
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

.ai-entry--active,
.ai-entry:hover {
  border-color: #d7e1e7;
  background: #fff;
  color: var(--text);
  box-shadow: 0 9px 18px rgba(27, 44, 67, 0.18);
}

.main-nav {
  width: 100%;
  display: grid;
  gap: 4px;
  justify-items: center;
}

.nav-item {
  width: 184px;
  min-height: 68px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 16px;
  border-radius: 20px;
  text-decoration: none;
  position: relative;
}

.nav-item span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #c9ced8;
  color: #1a2d49;
  font-size: 14px;
  font-weight: 800;
  flex: 0 0 auto;
}

.nav-item b {
  font-size: 16px;
  font-weight: 700;
}

.nav-item--active,
.nav-item:hover {
  color: var(--text);
  background: #fff;
  box-shadow: 0 9px 18px rgba(27, 44, 67, 0.18);
}

.nav-item--active::before {
  display: none;
}

.page-shell {
  flex: 1;
  min-width: 0;
  width: 100%;
  margin-left: 218px;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  min-height: 82px;
  padding: 22px 30px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

body:has(#portalView.view--active) .topbar {
  display: none;
}

body:has(#portalView.view--active) .content {
  padding-top: 30px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.2;
}

#pageEyebrow,
.article-panel .section-head span,
.record-panel > span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  display: none;
}

.runtime-pill {
  display: none;
  min-width: 130px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  align-items: center;
  gap: 10px;
  color: #53657c;
  white-space: nowrap;
}

.runtime-pill span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2bd36f;
  box-shadow: 0 0 0 8px rgba(43, 211, 111, 0.12);
}

.content {
  padding: 0 30px 34px;
}

.view {
  display: none;
}

.view--active {
  display: block;
}

.hero-card,
.detail-cover {
  width: min(1030px, 100%);
  min-height: 360px;
  border: 2px solid rgba(16, 24, 39, 0.82);
  border-radius: 28px;
  color: #fff;
  text-align: center;
  background: var(--cover);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

#portalView .hero-card {
  display: none;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.hero-card::before,
.detail-cover::before,
.article-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 8, 18, 0.02), rgba(2, 8, 18, 0.55)),
    radial-gradient(circle at 10% 16%, rgba(255, 255, 255, 0.16), transparent 16%),
    radial-gradient(circle at 78% 18%, rgba(255, 230, 184, 0.12), transparent 18%);
}

.hero-card > *,
.detail-cover > * {
  position: relative;
  z-index: 1;
}

.hero-card span,
.detail-cover span {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.32);
}

.hero-card h2 {
  margin: 18px 0 10px;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.25;
}

.hero-card p {
  margin: 0;
  max-width: 780px;
  line-height: 1.8;
  font-weight: 700;
}

.article-panel,
.detail-panel,
.record-panel,
.chat-panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.article-panel {
  margin-top: 0;
  border-radius: 28px;
  padding: 26px 24px 24px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 10px 0 0;
  font-size: 30px;
}

.section-head b {
  padding: 12px 18px;
  border-radius: 999px;
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.article-list {
  display: grid;
  gap: 14px;
}

.link-group {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  padding: 18px;
}

.link-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.link-group__head h3 {
  margin: 0;
  font-size: 18px;
  color: #24354c;
}

.link-group__head span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 10px;
}

.tool-link {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.tool-link:hover {
  transform: translateY(-2px);
  border-color: rgba(29, 158, 170, 0.42);
  box-shadow: 0 12px 26px rgba(40, 60, 82, 0.1);
}

.tool-link span {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.tool-link small {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-card {
  width: 100%;
  min-height: 216px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.74);
  text-align: left;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.article-thumb {
  position: relative;
  min-height: 180px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--cover);
}

.article-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.article-copy small {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.article-copy strong {
  display: block;
  color: #314058;
  font-size: 24px;
  line-height: 1.35;
}

.article-copy em {
  color: #68788f;
  font-style: normal;
  line-height: 1.7;
}

.article-copy span {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #677895;
  font-weight: 400;
}

.detail-panel {
  border-radius: 28px;
  padding: 24px;
}

.back-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 10px 16px;
  color: var(--brand-deep);
  margin-bottom: 18px;
}

.detail-cover {
  width: 100%;
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 34px;
}

.detail-cover h2 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.25;
}

.detail-meta {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.detail-meta span {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.detail-panel > h2 {
  margin: 20px 0 10px;
  font-size: clamp(26px, 3vw, 38px);
}

.detail-summary,
.detail-body p {
  color: #52647b;
  line-height: 1.9;
}

.detail-summary {
  font-size: 18px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 116px);
  position: relative;
}

.record-panel {
  border-radius: 14px;
  padding: 14px 8px;
  min-height: 544px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.record-panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.new-chat-button {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.employee-picker {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.employee-picker select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.history-group {
  display: grid;
  gap: 8px;
}

.history-group p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.history-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 8px 6px;
  color: var(--text);
  text-align: center;
  font-size: 12px;
}

.history-item strong,
.history-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  margin-top: 4px;
  color: var(--muted);
}

.history-item--active,
.history-item:hover {
  border-color: #2d7cff;
  background: rgba(45, 124, 255, 0.05);
}

.chat-panel {
  border-radius: 14px;
  min-height: 544px;
  padding: 28px 24px 80px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  overflow-y: auto;
}

.chat-welcome {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.chat-welcome h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.chat-welcome p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.chat-thread {
  flex: 1;
  min-height: 230px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 20px;
}

.message {
  max-width: min(760px, 90%);
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.7;
  box-shadow: 0 8px 20px rgba(35, 52, 73, 0.08);
}

.message div {
  display: flex;
  gap: 12px;
  color: inherit;
  opacity: 0.7;
  font-size: 12px;
}

.message p {
  margin: 6px 0 0;
}

.message--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.message--user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, #167f88, #246abf);
}

/* 输入框 最终精准宽度修复 */
.composer {
  position: fixed;
  bottom: 0;
  left: 30px;
  right: 30px;
  z-index: 999;
  height: 60px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  align-items: center;
  border-radius: 8px 8px 0 0;
  padding: 0 16px;
  gap: 12px;
  box-sizing: border-box;
}
.composer textarea {
  flex: 1;
  height: 40px;
  padding: 8px 12px;
  border: 0;
  resize: none;
  outline: none;
  background: transparent;
  line-height: 1.5;
  font-size: 14px;
}
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  flex-shrink: 0;
}
.composer-footer #chatHint {
  display: none;
}
.composer-footer button {
  width: 90px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state--small {
  padding: 10px 6px;
  font-size: 12px;
}

.mobile-mask {
  display: none;
}

@media (max-width: 1040px) {
  .article-card,
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .record-panel {
    min-height: auto;
  }
  .hero-card {
    min-height: 300px;
  }
}

/* 手机端适配 */
@media (max-width: 760px) {
  body:has(#portalView.view--active) .topbar {
    display: flex;
  }
  body:has(#portalView.view--active) .content {
    padding-top: 0;
  }
  .app-shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    width: min(82vw, 240px);
    height: 100dvh;
  }
  .sidebar--open {
    transform: translateX(0);
  }
  .page-shell {
    margin-left: 0;
  }
  .mobile-mask--show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 32, 0.28);
    z-index: 10;
  }
  .menu-toggle {
    display: grid;
    place-items: center;
  }
  .topbar {
    min-height: 66px;
    padding: 12px 14px;
    position: sticky;
    top: 0;
    z-index: 8;
    background: rgba(247, 249, 250, 0.9);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(219, 229, 234, 0.72);
  }
  .topbar h1 {
    font-size: 20px;
    margin-top: 2px;
  }
  .runtime-pill {
    display: none;
  }
  .content {
    padding: 14px 12px 22px;
  }
  .brand-block {
    width: 168px;
    height: 132px;
    border-radius: 18px 18px 0 0;
  }
  .brand-logo {
    width: 132px;
  }
  .ai-entry,
  .nav-item {
    width: calc(100% - 24px);
    min-height: 54px;
    border-radius: 16px;
    padding: 0 14px;
  }
  .ai-entry {
    font-size: 15px;
  }
  .nav-item b {
    font-size: 15px;
  }
  .article-panel,
  .detail-panel,
  .record-panel,
  .chat-panel {
    border-radius: 18px;
  }
  .article-panel {
    padding: 18px 14px;
  }
  .section-head,
  .article-copy span {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-head {
    gap: 8px;
    margin-bottom: 14px;
  }
  .section-head h2 {
    font-size: 24px;
  }
  .section-head b {
    padding: 8px 12px;
    font-size: 13px;
  }
  .link-group {
    padding: 14px;
    border-radius: 16px;
  }
  .link-group__head {
    align-items: flex-start;
    margin-bottom: 12px;
  }
  .link-grid {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    gap: 9px;
  }
  .tool-link {
    min-height: 78px;
    padding: 11px;
  }
  .tool-link span {
    font-size: 13px;
  }
  .article-card {
    grid-template-columns: 1fr;
  }
  .chat-layout {
    min-height: auto;
    gap: 12px;
  }
  .record-panel {
    padding: 14px;
    gap: 12px;
  }
  .record-panel h2 {
    font-size: 18px;
  }
  .chat-panel {
    min-height: calc(100dvh - 92px);
    padding: 16px 14px 80px;
    height: auto;
  }
  .chat-welcome {
    min-height: 120px;
  }
  .chat-welcome h2 {
    font-size: 18px;
  }
  .chat-thread {
    min-height: 220px;
  }
  .message {
    max-width: 96%;
    font-size: 14px;
  }
  /* 手机端输入框 */
    /* 手机端输入框 强制固定底部生效 */
  .composer {
    position: fixed !important;
    bottom: 0 !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    z-index: 9999 !important;
    border-radius: 8px 8px 0 0 !important;
    margin: 0 !important;
  }
}

@media (max-width: 420px) {
  .topbar h1 {
    font-size: 18px;
  }
  .content {
    padding-inline: 10px;
  }
  .article-panel {
    padding: 16px 12px;
  }
  .link-grid {
    grid-template-columns: 1fr;
  }
  .tool-link {
    min-height: 68px;
  }
}