:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --text: #1e2528;
  --muted: #667175;
  --line: #d8d2c8;
  --panel: #ffffff;
  --accent: #0d7f76;
  --accent-strong: #075f59;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(28, 32, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "SF Pro Display", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Vue 挂载前隐藏未编译模板，避免闪现 {{ stageText }} 等插值 */
[v-cloak] {
  display: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: flex;
  min-height: calc(100vh - 64px);
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
}

.status-pill {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  text-align: center;
  color: var(--accent-strong);
  background: #edf8f6;
}

/* ── Worker 状态 ─────────────────────────────────── */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.worker-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.worker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  flex-shrink: 0;
  transition: background .3s;
}

.worker-dot.online { background: #22c55e; }
.worker-dot.offline { background: #ef4444; }

.job-form {
  display: grid;
  gap: 12px;
}

.config-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.config-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.config-head h3 {
  font-size: 14px;
  margin: 0;
}

.config-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.url-rows {
  display: grid;
  gap: 8px;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr 36px 36px;
  gap: 6px;
}

.url-row .url-input {
  min-height: 48px;
}

.url-row-btn {
  width: 36px;
  min-height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.url-row-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eefaf8;
}

.url-row-btn:active {
  background: #daf3f0;
}

.url-row-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 127, 118, 0.16);
}

select:disabled {
  color: var(--muted);
  background: #faf9f7;
}

.auto-save-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}

.auto-save-label input[type="checkbox"] {
  width: auto;
  min-height: auto;
  cursor: pointer;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

button.ghost {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ── 状态行 ─────────────────────────────────── */

#stageText {
  margin: 10px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cookie-config {
  display: grid;
  gap: 6px;
}

.cookie-config label {
  font-size: 13px;
  color: var(--muted);
}

.cookie-config textarea {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  resize: vertical;
  font-family: "SF Mono", "Menlo", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.cookie-config textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 127, 118, 0.16);
}

.cookie-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cookie-row .ghost {
  min-height: 34px;
  flex-shrink: 0;
}

.cookie-status {
  font-size: 12px;
  color: var(--muted);
}

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

.channel-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.channel-sub {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  background: #faf9f7;
  border-radius: 6px;
}

.channel-sub + .channel-sub {
  margin-top: 2px;
}

.channel-sub-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.8;
}

.notion-detail {
  display: none;
  gap: 8px;
}

.notion-detail.visible {
  display: grid;
}

.login-btn {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.login-btn:hover {
  border-color: var(--accent);
  background: #eefaf8;
}

.login-btn:active {
  background: #daf3f0;
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.notion-auth-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notion-auth-row .ghost {
  min-height: 34px;
}

.channel-group + .channel-group {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* ── 任务历史 ─────────────────────────────────── */

.job-history {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.job-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.job-history-head h2 {
  font-size: 14px;
}

.job-count {
  font-size: 12px;
  color: var(--muted);
}

.job-list {
  max-height: 70vh;
  overflow-y: auto;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.page-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #faf9f7;
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 2px;
}

.job-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  transition: background .15s;
  cursor: pointer;
}

.job-item:last-child {
  border-bottom: 0;
}

.job-item:hover {
  background: #faf9f7;
}

.job-item.expanded {
  background: #faf9f7;
  cursor: default;
}

.job-detail-area {
  width: 100%;
}

.job-item-main {
  flex: 1;
  min-width: 0;
}

.job-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.job-badge {
  display: inline-block;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-queued  { background: #fef3c7; color: #92400e; }
.badge-running { background: #dbeafe; color: #1e40af; }
.badge-done    { background: #d1fae5; color: #065f46; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-multi   { background: #ede9fe; color: #6d28d9; }

.job-item-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.job-item-url-sub {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.job-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.job-item-stage {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.job-item-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.job-item-actions {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
}

.job-cancel-btn {
  width: 28px;
  height: 28px;
  min-height: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.job-cancel-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fef2f2;
}

.job-delete-btn {
  width: 28px;
  height: 28px;
  min-height: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.job-delete-btn:hover {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.job-notion-btn,
.job-local-btn {
  width: 28px;
  height: 28px;
  min-height: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.job-notion-btn:hover,
.job-local-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #f0faf9;
}

.job-retry-btn {
  width: 28px;
  height: 28px;
  min-height: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.job-retry-btn:hover {
  border-color: #d97706;
  color: #d97706;
  background: #fffbeb;
}

.job-read-btn {
  width: 28px;
  height: 28px;
  min-height: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.job-read-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #f0faf9;
}

.job-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── 任务展开详情 ─────────────────────────────── */

.job-detail {
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 4px;
  cursor: default;
}

.job-detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 10px;
}

.job-tab {
  min-height: 32px;
  padding: 6px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent !important;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}

.job-tab:hover {
  color: var(--text);
  background: transparent !important;
}

.job-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.job-tab-content {
  display: none;
}

.job-tab-content.active {
  display: block;
}

.job-tab-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.job-tab-toolbar .ghost {
  min-height: 28px;
  font-size: 12px;
}

/* 下载下拉菜单（HTML tab 工具栏）：主按钮默认下载 HTML，▾ 展开选择 MD/HTML/PDF */
.job-download-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.job-download-menu .job-download-main {
  border-radius: 6px 0 0 6px;
}

.job-download-menu .job-download-toggle {
  min-width: 26px;
  padding: 0 6px;
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.job-download-items {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 132px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.job-download-items button {
  width: 100%;
  text-align: left;
  border-radius: 6px;
}

/* 合集任务分篇选择器 */
.job-page-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.job-page-select {
  min-height: 30px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.job-page-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.job-detail-article {
  width: 100%;
  min-height: 100px;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
}

/* markdown 渲染后的 HTML 预览样式 */
.job-detail-html {
  width: 100%;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  background: #fff;
  word-break: break-word;
}

.job-detail-html h1,
.job-detail-html h2,
.job-detail-html h3,
.job-detail-html h4 {
  margin: 1.1em 0 0.5em;
  line-height: 1.35;
}

.job-detail-html h1:first-child,
.job-detail-html h2:first-child,
.job-detail-html h3:first-child {
  margin-top: 0;
}

.job-detail-html p {
  margin: 0.6em 0;
}

.job-detail-html ul,
.job-detail-html ol {
  margin: 0.6em 0;
  padding-left: 1.6em;
}

.job-detail-html li {
  margin: 0.25em 0;
}

.job-detail-html code {
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: #f4f2ef;
  font-family: "SF Mono", "Menlo", "Cascadia Mono", Consolas, monospace;
  font-size: 0.9em;
}

.job-detail-html pre {
  margin: 0.8em 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf9f7;
  overflow-x: auto;
}

.job-detail-html pre code {
  padding: 0;
  background: none;
}

.job-detail-html blockquote {
  margin: 0.8em 0;
  padding: 0.2em 1em;
  border-left: 3px solid var(--accent);
  background: #fafaf8;
  color: var(--muted);
}

.job-detail-html table {
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
  font-size: 13px;
}

.job-detail-html th,
.job-detail-html td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.job-detail-html th {
  background: #f7f6f4;
  font-weight: 600;
}

.job-detail-html img {
  max-width: 100%;
}

.job-detail-html a {
  color: var(--accent);
}

.job-detail-html hr {
  margin: 1.2em 0;
  border: none;
  border-top: 1px solid var(--line);
}

/* ── 阅读模式弹窗 ─────────────────────────────────── */

/* 打开弹窗时锁定页面滚动 */
body.reader-open {
  overflow: hidden;
}

.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px 16px;
  background: rgba(24, 26, 27, .55);
  overflow-y: auto;
  /* 兜底：弹窗已 Teleport 到 body（不继承 .job-item 的 cursor: pointer），
     这里再显式声明一次，防止 body 或外层未来设置光标影响弹窗 */
  cursor: default;
}

.reader-modal-panel {
  position: relative; /* 供阅读进度百分比标签定位 */
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: 92vh;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 阅读进度条：面板顶部 3px 细条，随阅读区滚动位置填充 */
.reader-progress {
  position: relative;
  height: 3px;
  flex-shrink: 0;
  background: #ece8e0;
  overflow: hidden;
}

.reader-progress-fill {
  height: 100%;
  background: var(--accent);
}

/* 阅读进度百分比：固定在阅读区右下角的小标签 */
.reader-progress-pill {
  position: absolute;
  right: 20px;
  bottom: 16px;
  z-index: 5;
  min-width: 46px;
  padding: 3px 10px;
  border: 1px solid rgba(216, 210, 200, .8);
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 2px 8px rgba(28, 32, 34, .08);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  pointer-events: none;
}

.reader-progress-pill.done {
  color: var(--accent-strong);
  border-color: rgba(13, 127, 118, .35);
}

.reader-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}

.reader-modal-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.reader-modal-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reader-modal-tools .ghost {
  min-height: 28px;
  font-size: 12px;
}

.reader-modal-close {
  width: 30px;
  height: 30px;
  min-height: auto;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}

.reader-modal-close:hover {
  background: #f0eeea;
  color: var(--text);
}

.reader-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 48px;
  background: #fff;
}

/* 阅读排版：内容列居中、字号行距更舒适；
   复用 .job-detail-html 的 markdown 排版规则，这里覆盖容器限制 */
.reader-modal-body .reader-prose {
  max-width: 720px;
  margin: 0 auto;
  max-height: none;
  overflow: visible;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 16px;
  line-height: 1.85;
  background: transparent;
}

/* ── Mermaid 图表 ─────────────────────────────────── */

/* 渲染前：代码块临时样式（居中白底，避免闪成代码块样式）；渲染失败时保留原文 */
pre:has(> code.language-mermaid) {
  background: #fff;
  text-align: center;
}

/* 渲染后的图表容器 */
.mermaid-block {
  margin: 1em 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
  overflow-x: auto;
}

.mermaid-block svg {
  max-width: 100%;
  height: auto;
}

/* 修复：文章容器（.job-detail-html / .reader-prose）的 line-height 1.8/1.85
   会被 Mermaid 标签内的 foreignObject 继承，使文字实际行高比 Mermaid 测量
   的标签框更高，多行标签（如 A["非线性激活函数<br>（逐维度独立）"]）的
   第二行底部会被 foreignObject 裁掉。这里重置标签行高并允许溢出兜底。 */
.mermaid-block svg foreignObject,
pre:has(> code.language-mermaid) svg foreignObject {
  overflow: visible;
}
.mermaid-block svg foreignObject div,
.mermaid-block svg foreignObject span,
.mermaid-block svg foreignObject p,
pre:has(> code.language-mermaid) svg foreignObject div,
pre:has(> code.language-mermaid) svg foreignObject span,
pre:has(> code.language-mermaid) svg foreignObject p {
  line-height: 1.3;
}

/* KaTeX 公式：独立行公式超宽时可横向滚动，避免撑破版面 */
.job-detail-html .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

@media (max-width: 640px) {
  .reader-modal {
    padding: 0;
    align-items: stretch;
  }

  .reader-modal-panel {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .reader-modal-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .reader-modal-tools {
    flex-wrap: wrap;
  }

  .reader-modal-head button,
  .reader-modal-tools .job-page-select {
    width: auto;
  }

  .reader-modal-body {
    padding: 20px 16px 40px;
  }
}

.job-detail-transcript,
.job-detail-logs {
  width: 100%;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: "SF Mono", "Menlo", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #344044;
  background: #faf9f7;
  white-space: pre-wrap;
  word-break: break-word;
}

.job-item-stage.error-text {
  color: var(--danger);
  font-weight: 500;
}

@media (max-width: 980px) {
  .job-detail-tabs {
    overflow-x: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 1280px);
    padding: 16px 0;
  }

  .workspace {
    min-height: calc(100vh - 32px);
  }

  .topbar,
  .url-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 26px;
  }

  button {
    width: 100%;
  }
}

/* ── 顶部导航栏 ─────────────────────────────────── */

.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: background .2s, color .2s;
}

.nav-link:hover {
  background: #f0eeea;
  color: var(--text);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-username {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.main-nav .ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.main-nav .ghost:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── 登录 / 注册页 ─────────────────────────────────── */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  text-align: center;
}

.auth-card h1 {
  font-size: 26px;
  margin-bottom: 6px;
}

.auth-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-form {
  display: grid;
  gap: 16px;
  text-align: left;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
}

.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 127, 118, .12);
}

.auth-form button {
  margin-top: 6px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.auth-form button:hover {
  background: var(--accent-strong);
}

.auth-form button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.auth-error {
  font-size: 13px;
  color: var(--danger);
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
}

.auth-switch {
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
}

.auth-google:hover {
  background: #f7f7f7;
  border-color: #c5c5c5;
}

.auth-google svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── 设置页 ─────────────────────────────────── */

.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 10px;
}

.hint a {
  color: var(--accent-strong);
}

.server-info p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.user-row:last-child {
  border-bottom: none;
}

.user-info {
  display: grid;
  gap: 2px;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
}

.user-meta {
  font-size: 12px;
  color: var(--muted);
}

.user-row .ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.user-row .ghost:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── 知识库问答 ─────────────────────────────────── */
.kb-workspace {
  gap: 14px;
}

.kb-notice {
  border: 1px solid #e6b84c;
  background: #fff8e6;
  color: #7a5b00;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
}
.kb-notice code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.kb-chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  scroll-behavior: smooth;
}

.kb-welcome {
  margin: auto;
  text-align: center;
  max-width: 620px;
  padding: 24px 12px;
}
.kb-welcome-icon {
  font-size: 44px;
  margin-bottom: 10px;
}
.kb-welcome h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.kb-welcome p {
  color: var(--muted);
  line-height: 1.7;
}
.kb-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}
.kb-sample {
  border: 1px solid var(--line);
  background: #f7f5f0;
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.kb-sample:hover {
  background: #edf8f6;
  border-color: var(--accent);
}

.kb-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.kb-msg.user {
  flex-direction: row-reverse;
}
.kb-msg-label {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  margin-top: 4px;
  user-select: none;
}
.kb-msg.user .kb-msg-label {
  background: #4b5563;
}
.kb-bubble {
  max-width: 82%;
  border-radius: 12px;
  padding: 12px 16px;
  line-height: 1.75;
  font-size: 14.5px;
  background: #f1f1ee;
  overflow-wrap: break-word;
}
.kb-msg.user .kb-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}
.kb-msg.assistant .kb-bubble {
  background: #f7f7f5;
  border: 1px solid var(--line);
  border-bottom-left-radius: 2px;
}
.kb-user-text {
  white-space: pre-wrap;
}

/* 回答内容的 Markdown 排版 */
.kb-answer {
  color: var(--text);
}
.kb-answer > :first-child {
  margin-top: 0;
}
.kb-answer > :last-child {
  margin-bottom: 0;
}
.kb-answer p {
  margin: 8px 0;
}
.kb-answer h1, .kb-answer h2, .kb-answer h3, .kb-answer h4 {
  margin: 14px 0 8px;
  line-height: 1.35;
}
.kb-answer h1 { font-size: 20px; }
.kb-answer h2 { font-size: 18px; }
.kb-answer h3 { font-size: 16px; }
.kb-answer h4 { font-size: 15px; }
.kb-answer ul, .kb-answer ol {
  margin: 8px 0;
  padding-left: 22px;
}
.kb-answer li {
  margin: 3px 0;
}
.kb-answer table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 13.5px;
}
.kb-answer th, .kb-answer td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.kb-answer th {
  background: #eef1ef;
}
.kb-answer blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--accent);
  background: #eef8f6;
  color: #3d5a55;
  border-radius: 0 6px 6px 0;
}
.kb-answer code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "JetBrains Mono", Consolas, monospace;
}
.kb-answer pre {
  background: #1e2528;
  color: #e8eaeb;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
}
.kb-answer pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}
.kb-answer a {
  color: var(--accent-strong);
}
.kb-answer .mermaid-block {
  margin: 10px 0;
  overflow-x: auto;
}

/* 思考过程 */
.kb-reasoning {
  margin: 0 0 8px;
  font-size: 13px;
}
.kb-reasoning summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
.kb-reasoning-text {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f0efe9;
  border-radius: 8px;
  color: #6b6f70;
  white-space: pre-wrap;
  font-size: 13px;
  max-height: 260px;
  overflow-y: auto;
}

/* 打字指示器 */
.kb-typing {
  display: inline-flex;
  gap: 4px;
  padding: 6px 2px;
}
.kb-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: kbBlink 1.2s infinite both;
}
.kb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.kb-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes kbBlink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.kb-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 13.5px;
  background: #fff5f5;
  border: 1px solid #f3c6c2;
  border-radius: 8px;
  padding: 8px 12px;
}

/* 参考来源 */
.kb-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
}
.kb-sources-label {
  font-size: 12px;
  color: var(--muted);
}
.kb-source-chip {
  font-size: 12px;
  color: var(--accent-strong);
  background: #eaf6f4;
  border: 1px solid #cde8e3;
  border-radius: 999px;
  padding: 3px 10px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

/* 输入区 */
.kb-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.kb-input {
  flex: 1;
  resize: vertical;
  min-height: 52px;
  max-height: 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14.5px;
  line-height: 1.6;
  background: var(--panel);
  color: var(--text);
  outline: none;
}
.kb-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 127, 118, 0.12);
}
.kb-input:disabled {
  opacity: 0.6;
}
.kb-send {
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  font-size: 14.5px;
  cursor: pointer;
  transition: background 0.2s;
}
.kb-send:hover:not(:disabled) {
  background: var(--accent-strong);
}
.kb-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
