/* 大卖 · 现代 AI 工作台风格（参考墨刀类 AI 产品：柔和渐变、毛玻璃、对话优先） */
:root {
  --color-primary: #2563eb;
  --drp-blue: #1890ff;
  --color-primary-soft: rgba(37, 99, 235, 0.12);
  --gradient-brand: linear-gradient(135deg, #2563eb 0%, #7c3aed 55%, #a855f7 100%);
  --gradient-mesh: radial-gradient(ellipse 120% 80% at 100% -20%, rgba(124, 58, 237, 0.14), transparent 50%),
    radial-gradient(ellipse 80% 60% at -10% 50%, rgba(37, 99, 235, 0.1), transparent 45%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(168, 85, 247, 0.08), transparent 40%);
  --color-bg: #f4f6fb;
  --color-surface: rgba(255, 255, 255, 0.72);
  --color-card: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #64748b;
  --color-text-hint: #94a3b8;
  --color-border: rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 32px rgba(15, 23, 42, 0.08);
  --shadow-composer: 0 -4px 40px rgba(15, 23, 42, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --header-h: 56px;
  --sidebar-w: 232px;
  --font-sans: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: 600 1.5rem/1.35 var(--font-sans);
  --font-body: 400 0.9375rem/1.6 var(--font-sans);
  --font-small: 400 0.8125rem/1.5 var(--font-sans);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: var(--gradient-mesh);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

/* —— 顶栏：毛玻璃 —— */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  background: var(--color-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
}

.app-header__left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 180px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 1.125rem var(--font-sans);
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.app-header__brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  line-height: 1.2;
}

.app-header__brand-name {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.app-header__brand-tag {
  font: 500 0.6875rem var(--font-sans);
  letter-spacing: 0.02em;
  color: var(--color-text-hint);
  text-transform: none;
}

/* 品牌 = 回对话首页（替代顶栏正中的「对话模式」按钮） */
a.app-header__brand--link {
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 4px 8px 4px 4px;
  margin: -4px -8px -4px -4px;
  transition: background 0.15s;
}

a.app-header__brand--link:hover {
  background: rgba(15, 23, 42, 0.06);
}

a.app-header__brand--link:hover .app-header__brand-tag {
  color: var(--color-text-secondary);
}

.app-header__brand--here {
  padding: 4px 8px 4px 4px;
  margin: -4px -8px -4px -4px;
  border-radius: var(--radius-sm);
  cursor: default;
}

.app-header__brand--here .app-header__brand-tag {
  color: var(--color-primary);
}

.app-header__brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(15, 23, 42, 0.05);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: background 0.15s, color 0.15s;
}

.sidebar-toggle:hover {
  background: rgba(15, 23, 42, 0.08);
  color: var(--color-text);
}

/* 顶栏中部留白，避免「对话入口」挤在正中间显得突兀 */
.app-header__spacer {
  flex: 1;
  min-width: 0;
}

.app-header__right {
  min-width: 200px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.user-pill {
  font: var(--font-small);
  color: var(--color-text-secondary);
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.04);
  border-radius: var(--radius-pill);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  font: 500 0.875rem var(--font-sans);
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn--ghost:hover {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.12);
}

.btn--soft {
  background: rgba(15, 23, 42, 0.05);
  color: var(--color-text-secondary);
  border: none;
}

.btn--soft:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

/* —— 布局 —— */
.app-shell {
  padding-top: var(--header-h);
  min-height: 100%;
  display: flex;
}

.app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  padding: 16px 12px;
  overflow-y: auto;
  z-index: 90;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-sidebar__section {
  font: 600 0.6875rem var(--font-sans);
  color: var(--color-text-hint);
  padding: 12px 14px 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 2px;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.app-sidebar__link:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--color-text);
  text-decoration: none;
}

.app-sidebar__link.is-active {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  border-color: rgba(37, 99, 235, 0.15);
}

.nav-ic {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.app-sidebar__link.is-active .nav-ic {
  opacity: 1;
  color: var(--color-primary);
}

.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px 140px;
  min-height: calc(100vh - var(--header-h));
  max-width: 1200px;
  width: 100%;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 首页：主文案垂直水平居中（功能仅保留侧栏 + 底栏对话） */
.app-main--home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: none;
  padding-bottom: 200px;
  min-height: calc(100vh - var(--header-h));
}

.app-main--home .hero {
  margin-bottom: 0;
  text-align: center;
  max-width: 640px;
}

.app-main--home .hero__eyebrow {
  margin-left: auto;
  margin-right: auto;
}

.app-main--home .hero__desc {
  margin-left: auto;
  margin-right: auto;
}

/* 对话工作台：参考豆包 — 中间窄阅读栏 + 助手偏文档流 + 用户右侧气泡 */
.app-main--home.app-main--workbench {
  justify-content: flex-start;
  align-items: stretch;
  align-self: stretch;
  max-width: none;
  width: 100%;
  margin-right: 0;
  padding: 20px 0 200px;
  min-height: calc(100vh - var(--header-h));
}

.chat-workbench-col {
  max-width: 720px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 0 20px;
  box-sizing: border-box;
}

.chat-workbench-col .chat-empty .hero {
  padding-top: min(10vh, 72px);
}

.chat-thread {
  flex: 1;
  min-height: 180px;
  max-height: calc(100vh - var(--header-h) - 260px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 12px 0 24px;
  margin-bottom: 4px;
  scrollbar-gutter: stable;
}

.chat-thread:not(:empty) ~ .chat-empty {
  display: none;
}

.chat-bubble {
  max-width: 100%;
  padding: 0;
  border-radius: 0;
  line-height: 1.75;
  word-break: break-word;
  font-size: 15px;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  color: #27272a;
}

/* 用户：右侧小气泡（浅灰） */
.chat-bubble--user {
  align-self: flex-end;
  max-width: min(92%, 520px);
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  color: #18181b;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.65;
}

/* 助手：无重卡片，正文直接落在背景上（豆包式） */
.chat-bubble--assistant {
  align-self: stretch;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 4px 0 8px;
}

.chat-bubble--assistant.chat-bubble--pending,
.chat-bubble--assistant.chat-bubble--error {
  padding: 12px 0;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.chat-bubble--pending {
  font-style: normal;
}

/* 等待模型/知识库查询时：文字明暗闪动，提示仍在生成 */
@keyframes chat-thinking-flash {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 1;
  }
}

.chat-bubble--assistant.chat-bubble--thinking {
  animation: chat-thinking-flash 1.05s ease-in-out infinite;
  will-change: opacity;
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble--assistant.chat-bubble--thinking {
    animation: none;
    opacity: 0.85;
  }
}

.chat-bubble--error {
  color: #b91c1c !important;
  font-style: normal;
}

/* Markdown 正文：与全站同一套中文无衬线，层级与重点强化 */
.chat-md {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  color: #27272a;
  font-weight: 400;
}

.chat-md > *:first-child {
  margin-top: 0;
}

.chat-md > *:last-child {
  margin-bottom: 0;
}

.chat-md h1,
.chat-md h2,
.chat-md h3 {
  font-family: var(--font-sans);
  color: #18181b;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin: 1.25em 0 0.5em;
}

.chat-md h1 {
  font-size: 1.375rem;
  font-weight: 700;
}

.chat-md h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 1.5em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid #e4e4e7;
}

.chat-md h3 {
  font-size: 1.05rem;
  font-weight: 650;
  color: #1e293b;
}

.chat-md p {
  margin: 0.65em 0;
}

.chat-md strong,
.chat-md b {
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.01em;
}

.chat-md ul,
.chat-md ol {
  margin: 0.5em 0;
  padding-left: 1.35em;
}

.chat-md li {
  margin: 0.35em 0;
}

.chat-md hr {
  border: none;
  border-top: 1px solid #e4e4e7;
  margin: 1.25em 0;
}

.chat-md code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(15, 23, 42, 0.06);
  padding: 0.12em 0.4em;
  border-radius: 4px;
}

.chat-md pre {
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  margin: 0.85em 0;
}

.chat-md pre code {
  background: none;
  padding: 0;
}

.chat-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 1em 0;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  overflow: hidden;
}

.chat-md th,
.chat-md td {
  border: 1px solid #e4e4e7;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.chat-md th {
  background: #f4f4f5;
  font-weight: 600;
  color: #18181b;
}

.chat-md tbody tr:nth-child(even) {
  background: rgba(244, 244, 245, 0.5);
}

/* 表格首列常为「楼栋」等维度，略加重 */
.chat-md tbody td:first-child {
  font-weight: 600;
  color: #1e293b;
}

.chat-md blockquote {
  margin: 0.75em 0;
  padding: 10px 14px 10px 16px;
  border-left: 4px solid rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.06);
  border-radius: 0 8px 8px 0;
  color: #334155;
  font-size: 0.95em;
}

/* 底栏与中间栏同宽（豆包式圆角输入容器） */
.composer-dock--workbench .composer-dock__inner--narrow {
  max-width: 720px;
}

.composer-dock__inner--narrow {
  border-radius: 20px;
}

.app-shell.sidebar-collapsed .app-main {
  margin-left: 0;
}

.app-shell.sidebar-collapsed .app-sidebar {
  transform: translateX(-100%);
  /* 收起后避免固定侧栏仍参与点击命中 */
  pointer-events: none;
}

/* —— 首页 Hero —— */
.hero {
  margin-bottom: 32px;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: var(--font-small);
  color: var(--color-primary);
  background: var(--color-primary-soft);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
}

.hero__title {
  margin: 0 0 12px;
  font: 700 2rem/1.25 var(--font-sans);
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, #0f172a 0%, #334155 40%, #4f46e5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__desc {
  margin: 0;
  max-width: 520px;
  font-size: 1rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
}

/* —— Bento 功能卡片 —— */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.func-card {
  position: relative;
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, border-color 0.2s;
}

.func-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle at top right, rgba(124, 58, 237, 0.08), transparent 70%);
  pointer-events: none;
}

.func-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.2);
}

.func-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #fff;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.25);
}

.func-card__icon svg {
  width: 22px;
  height: 22px;
}

.func-card__title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--color-text);
}

.func-card__desc {
  font: var(--font-small);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.func-card--muted .func-card__icon {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  box-shadow: none;
}

/* —— 底部悬浮对话（类墨刀/豆包输入条） —— */
.composer-dock {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  /* 须高于侧栏 z-index:90，否则底栏按钮在部分分辨率下点不到 */
  z-index: 120;
  padding: 16px 32px 24px;
  background: linear-gradient(to top, rgba(244, 246, 251, 0.98) 60%, transparent);
  pointer-events: none;
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-shell.sidebar-collapsed + .composer-dock,
body.sidebar-collapsed .composer-dock {
  left: 0;
}

.composer-dock__inner {
  pointer-events: auto;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-composer), var(--shadow-md);
  padding: 12px 12px 12px 16px;
}

.composer-dock__label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font: 600 0.8125rem var(--font-sans);
  color: var(--color-text-secondary);
  margin-bottom: 10px;
  padding-left: 4px;
}

.composer-dock__hint {
  flex: 1 1 100%;
  font: 500 0.75rem var(--font-sans);
  color: #b45309;
  margin: 0;
  padding-left: 28px;
}

.composer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.composer-tools .btn {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.composer-field {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(15, 23, 42, 0.03);
  border-radius: var(--radius-md);
  padding: 8px 8px 8px 14px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}

.composer-field:focus-within {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.composer-field textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 0;
  border: none;
  background: transparent;
  resize: none;
  font: var(--font-body);
  font-family: var(--font-sans);
  outline: none;
}

.composer-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transition: transform 0.12s, filter 0.15s;
}

.composer-send:hover {
  filter: brightness(1.06);
}

.composer-send:active {
  transform: scale(0.96);
}

.composer-send svg {
  width: 20px;
  height: 20px;
}

/* —— 通用页面标题 —— */
.page-title {
  font: 700 1.375rem/1.3 var(--font-sans);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.page-desc {
  font: var(--font-small);
  color: var(--color-text-secondary);
  margin: 0 0 24px;
  max-width: 640px;
  line-height: 1.6;
}

.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.field-label {
  font: var(--font-small);
  color: var(--color-text-secondary);
  margin-right: 4px;
}

.input,
.select {
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  min-width: 160px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

/* —— 分段 Tab（替换旧 button tabs） —— */
.tabs-segment {
  display: inline-flex;
  padding: 4px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: var(--radius-md);
  gap: 4px;
  margin-bottom: 20px;
}

.tabs-segment button {
  padding: 8px 20px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font: 500 0.875rem var(--font-sans);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tabs-segment button:hover {
  color: var(--color-text);
}

.tabs-segment button.is-active {
  background: #fff;
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(15, 23, 42, 0.02);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(37, 99, 235, 0.03);
}

.link-action {
  color: var(--color-primary);
  cursor: pointer;
  background: none;
  border: none;
  font: 500 0.875rem var(--font-sans);
  padding: 0;
}

.link-action:hover {
  text-decoration: underline;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font: var(--font-small);
  color: var(--color-text-secondary);
}

.pagination button {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  font-size: 0.8125rem;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 写脚本：对话 | 章节 | 成稿 */
.layout-script {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 200px minmax(260px, 1fr);
  gap: 16px;
  min-height: calc(100vh - var(--header-h) - 120px);
  align-items: stretch;
}

@media (max-width: 1100px) {
  .layout-script {
    grid-template-columns: 1fr;
  }

  .layout-script .script-col--chapters {
    order: 3;
    max-height: 200px;
  }
}

.script-col--chapters {
  min-width: 0;
}

.chapter-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
}

.chapter-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.02);
  font: 500 0.8125rem var(--font-sans);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chapter-item:hover {
  background: var(--color-primary-soft);
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--color-primary);
}

.chapter-item.is-active {
  background: var(--color-primary-soft);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--color-primary);
}

.chapter-empty {
  font: var(--font-small);
  color: var(--color-text-hint);
  line-height: 1.55;
  margin: 0;
}

.script-output--flash {
  animation: chapterFlash 0.6s ease;
}

@keyframes chapterFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.5);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.script-col {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  box-shadow: var(--shadow-sm);
}

.script-col__head {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.script-chat-area {
  flex: 1;
  overflow-y: auto;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
  line-height: 1.65;
}

.script-output {
  flex: 1;
  min-height: 200px;
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  resize: vertical;
  transition: border-color 0.15s;
}

.script-output:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
}

.script-output-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
}

.chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-hint);
  font-size: 18px;
  line-height: 1;
}

.bar-chart-mock {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
}

.bar-chart-mock span {
  width: 8px;
  background: var(--gradient-brand);
  border-radius: 3px;
  opacity: 0.9;
}

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

.modal__close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(15, 23, 42, 0.05);
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-hint);
}

.modal__body {
  padding: 22px;
  overflow-y: auto;
}

.modal--narrow {
  max-width: 420px;
}

.is-hidden {
  display: none !important;
}

/* C 端登录弹窗表单 */
.app-login-tip {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin: 0 0 16px;
}

.app-login-field {
  margin-bottom: 14px;
}

.app-login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.app-login-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  box-sizing: border-box;
}

.app-login-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.app-login-captcha-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.app-login-captcha-row .app-login-input {
  flex: 1;
}

.app-login-hint {
  font-size: 0.75rem;
  color: var(--color-text-hint);
  margin: 8px 0 0;
}

.app-login-submit {
  width: 100%;
  margin-top: 8px;
  height: 42px;
  justify-content: center;
}

.skeleton {
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.04) 25%, rgba(15, 23, 42, 0.08) 50%, rgba(15, 23, 42, 0.04) 75%);
  background-size: 200% 100%;
  animation: sk 1.2s ease infinite;
  border-radius: var(--radius-sm);
  height: 14px;
  margin: 8px 0;
}

@keyframes sk {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.state-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-hint);
  font-size: 0.875rem;
}

.state-error {
  color: #b91c1c;
  font-size: 0.875rem;
  padding: 12px 16px;
  background: #fef2f2;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

/* —— 统一下拉框样式 —— */
.select-wrap {
  position: relative;
  display: inline-block;
  min-width: 140px;
}

.select-wrap select,
select.select--styled {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 36px 9px 14px;
  font: 500 0.875rem var(--font-sans);
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-wrap select:hover,
select.select--styled:hover {
  border-color: rgba(15, 23, 42, 0.14);
}

.select-wrap select:focus,
select.select--styled:focus {
  outline: none;
  border-color: rgba(24, 144, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.15);
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    center/contain no-repeat;
  pointer-events: none;
}

select.select--styled option,
.select-wrap select option {
  padding: 10px 14px;
  background: #fff;
  color: var(--color-text);
  font-size: 0.875rem;
}

/* —— 日期范围（参考 Ant 风：#1890ff 选中圆点 + 左侧快捷） —— */
.drp {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.drp-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  padding: 9px 14px 9px 14px;
  font: 0.875rem var(--font-sans);
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.drp-trigger::after {
  content: "";
  margin-left: auto;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.5'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E")
    center/contain no-repeat;
}

.drp-trigger:hover,
.drp-trigger:focus {
  border-color: rgba(24, 144, 255, 0.45);
  outline: none;
}

.drp-popover {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 150;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 48px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.drp-popover.is-open {
  display: flex;
}

.drp-presets {
  width: 118px;
  flex-shrink: 0;
  padding: 10px 0;
  border-right: 1px solid var(--color-border);
  background: rgba(15, 23, 42, 0.02);
}

.drp-preset {
  display: block;
  width: 100%;
  padding: 9px 16px;
  border: none;
  background: none;
  font: 0.8125rem var(--font-sans);
  color: var(--color-text-secondary);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.drp-preset:hover {
  background: rgba(24, 144, 255, 0.08);
  color: var(--drp-blue);
}

.drp-cal-area {
  padding: 12px 16px 16px;
  min-width: 520px;
}

.drp-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 8px;
  gap: 8px;
}

.drp-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1;
}

.drp-nav:hover {
  border-color: var(--drp-blue);
  color: var(--drp-blue);
}

.drp-cal-row {
  display: flex;
  gap: 24px;
}

.drp-cal {
  flex: 1;
  min-width: 0;
}

.drp-cal__title {
  text-align: center;
  font: 600 0.875rem var(--font-sans);
  margin-bottom: 10px;
  color: var(--color-text);
}

.drp-cal__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.drp-cal__week span {
  text-align: center;
  font: 600 0.6875rem var(--font-sans);
  color: var(--color-text-hint);
  padding: 4px 0;
}

.drp-cal__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.drp-day {
  aspect-ratio: 1;
  max-height: 34px;
  border: none;
  border-radius: 50%;
  background: none;
  font: 0.8125rem var(--font-sans);
  color: var(--color-text);
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}

.drp-day:hover:not(.drp-day--muted) {
  background: rgba(24, 144, 255, 0.12);
}

.drp-day--muted {
  color: var(--color-text-hint);
  cursor: default;
  opacity: 0.45;
}

.drp-day--in-range {
  background: rgba(24, 144, 255, 0.1);
  border-radius: 6px;
}

.drp-day--selected {
  background: var(--drp-blue) !important;
  color: #fff !important;
  font-weight: 600;
}

@media (max-width: 640px) {
  .drp-popover {
    flex-direction: column;
    max-width: calc(100vw - 24px);
  }

  .drp-presets {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding: 8px;
    gap: 4px;
  }

  .drp-cal-area {
    min-width: 0;
    width: 100%;
  }

  .drp-cal-row {
    flex-direction: column;
  }
}
