/* === Theme Variables === */
:root {
  /* Light (default) */
  --color-bg:             #ffffff;
  --color-bg-muted:       #f6f8fa;
  --color-bg-highlight:   #ddf4ff;
  --color-text:           #1f2328;
  --color-text-muted:     #656d76;
  --color-link:           #0969da;
  --color-border:         #d1d9e0;
  --color-header-bg:      #24292f;
  --color-header-text:    #ffffff;
  --color-header-muted:   #8b949e;
  --color-badge-bg:       #ddf4ff;
  --color-badge-text:     #0969da;
  --color-badge-border:   #54aeff66;
  --color-code-bg:        #eff1f3;
  --color-icon-dir:       #54aeff;
  --color-icon-file:      #656d76;
  --color-blockquote:     #656d76;
  --color-blockquote-border: #d1d9e0;
  --color-iframe-bg:      #ffffff;
  --fund-positive:        #dc2626;
  --fund-negative:        #16a34a;
  --fund-card-bg:         #ffffff;
  --fund-card-border:     #d1d9e0;
}

[data-theme="paper"] {
  --color-bg:             #faf6f0;
  --color-bg-muted:       #f3ede4;
  --color-bg-highlight:   #ede4d4;
  --color-text:           #3d3529;
  --color-text-muted:     #8a7e6b;
  --color-link:           #8b5e3c;
  --color-border:         #e0d5c4;
  --color-header-bg:      #4a4035;
  --color-header-text:    #faf6f0;
  --color-header-muted:   #b5a998;
  --color-badge-bg:       #ede4d4;
  --color-badge-text:     #8b5e3c;
  --color-badge-border:   #c4a882aa;
  --color-code-bg:        #eee7db;
  --color-icon-dir:       #b8924a;
  --color-icon-file:      #8a7e6b;
  --color-blockquote:     #8a7e6b;
  --color-blockquote-border: #e0d5c4;
  --color-iframe-bg:      #faf6f0;
  --fund-positive:        #b91c1c;
  --fund-negative:        #15803d;
  --fund-card-bg:         #f3ede4;
  --fund-card-border:     #e0d5c4;
}

[data-theme="dark"] {
  --color-bg:             #0a0b0f;
  --color-bg-muted:       #1c1d28;
  --color-bg-highlight:   #252636;
  --color-text:           #e8e6e1;
  --color-text-muted:     #9a9890;
  --color-link:           #6ee7b7;
  --color-border:         rgba(255,255,255,0.06);
  --color-header-bg:      #0a0b0f;
  --color-header-text:    #e8e6e1;
  --color-header-muted:   #5c5b56;
  --color-badge-bg:       #252636;
  --color-badge-text:     #6ee7b7;
  --color-badge-border:   rgba(110,231,183,0.2);
  --color-code-bg:        #252636;
  --color-icon-dir:       #6ee7b7;
  --color-icon-file:      #9a9890;
  --color-blockquote:     #9a9890;
  --color-blockquote-border: rgba(255,255,255,0.06);
  --color-iframe-bg:      #14151e;
  --fund-positive:        #f87171;
  --fund-negative:        #6ee7b7;
  --fund-card-bg:         #14151e;
  --fund-card-border:     rgba(255,255,255,0.06);
}

[data-theme="fund"] {
  --color-bg:             #0a0b0f;
  --color-bg-muted:       #12131a;
  --color-bg-highlight:   #1a1b24;
  --color-text:           #e8e6e1;
  --color-text-muted:     #9a9890;
  --color-link:           #6ee7b7;
  --color-border:         rgba(255,255,255,0.06);
  --color-header-bg:      #0a0b0f;
  --color-header-text:    #e8e6e1;
  --color-header-muted:   #5c5b56;
  --color-badge-bg:       #1a1b24;
  --color-badge-text:     #6ee7b7;
  --color-badge-border:   rgba(110,231,183,0.2);
  --color-code-bg:        #1a1b24;
  --color-icon-dir:       #6ee7b7;
  --color-icon-file:      #9a9890;
  --color-blockquote:     #9a9890;
  --color-blockquote-border: rgba(255,255,255,0.06);
  --color-iframe-bg:      #0a0b0f;
  --fund-positive:        #f87171;
  --fund-negative:        #6ee7b7;
  --fund-card-bg:         #14151e;
  --fund-card-border:     rgba(255,255,255,0.06);
  color-scheme: dark;
}

/* === Reset & Base === */
html { scrollbar-gutter: stable; }
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Header === */
.site-header {
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
}
.header-nav {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-logo {
    color: var(--color-header-text);
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
}
.header-logo:hover { color: var(--color-header-muted); text-decoration: none; }
.header-nav-item.muted {
    color: var(--color-header-muted);
    font-size: 14px;
    cursor: default;
}

/* === Section Tabs === */
.section-tabs {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.section-tabs-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.section-tabs-inner::-webkit-scrollbar { display: none; }
.section-tab {
  padding: 8px 16px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.section-tab:hover {
  color: var(--color-text);
  text-decoration: none;
}
.section-tab.active {
  color: var(--color-text);
  font-weight: 600;
  border-bottom-color: var(--color-link);
}
.tab-icon {
  width: 16px;
  height: 16px;
  vertical-align: text-bottom;
  margin-right: 4px;
}

/* === Tab Dropdown (AI数据库) === */
.section-tab-dropdown {
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
}
.section-tab-label {
  display: flex;
  align-items: center;
  gap: 2px;
}
.dropdown-chevron {
  margin-left: 2px;
  transition: transform 0.2s;
}
.section-tab-dropdown.open .dropdown-chevron {
  transform: rotate(180deg);
}
.tab-dropdown-menu {
  display: none;
  position: fixed;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 140px;
  z-index: 100;
  padding: 4px 0;
}
.section-tab-dropdown.open .tab-dropdown-menu {
  display: block;
}
.tab-dropdown-item {
  display: block;
  padding: 8px 16px;
  color: var(--color-text-muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.tab-dropdown-item:hover {
  background: var(--color-bg-muted, rgba(0,0,0,0.04));
  text-decoration: none;
}
.tab-dropdown-item.active {
  color: var(--color-text);
  font-weight: 600;
}

/* === Container === */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === Repo Header === */
.repo-header { margin-bottom: 16px; }
.repo-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}

/* === Back Link === */
.back-link {
    font-size: 14px;
    margin-bottom: 8px;
    padding: 4px 0;
}
.back-link a { color: var(--color-link); }

/* === File Table === */
.file-table-container {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}
.file-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}
.file-table thead tr {
    background: var(--color-bg-muted);
}
.file-table th {
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.file-table td {
    padding: 8px 16px;
    vertical-align: middle;
}
.file-table tbody tr {
    border-bottom: 1px solid var(--color-border);
}
.file-table tbody tr:last-child {
    border-bottom: none;
}
.file-table tbody tr:hover {
    background: var(--color-bg-muted);
}
.file-table tbody tr.row-clickable {
    cursor: pointer;
}
.col-name {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* For th, don't use flex */
th.col-name { display: table-cell; }
.col-time {
    white-space: nowrap;
    color: var(--color-text-muted);
    font-size: 12px;
}
.icon-dir, .icon-file {
    flex-shrink: 0;
}
.col-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-fav {
  width: 64px;
  text-align: center;
  white-space: nowrap;
}
.inline-time {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

/* === Badge === */
.badge {
    display: inline-block;
    background: var(--color-badge-bg);
    color: var(--color-badge-text);
    font-size: 12px;
    font-weight: 500;
    padding: 0 7px;
    border-radius: 24px;
    border: 1px solid var(--color-badge-border);
    line-height: 20px;
    margin-left: 4px;
    vertical-align: middle;
}

/* === Report Preview === */
.report-preview {
    margin-top: 24px;
}
.preview-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
#report-frame,
.file-frame-container iframe {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    height: 600px;
    background: var(--color-iframe-bg);
}

/* === Markdown Body === */
.markdown-body {
    padding: 24px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
    word-wrap: break-word;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}
.markdown-body h1 { font-size: 2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--color-border); }
.markdown-body h2 { font-size: 1.5em; padding-bottom: 0.3em; border-bottom: 1px solid var(--color-border); }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body p { margin-top: 0; margin-bottom: 16px; }
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 16px;
}
.markdown-body table th,
.markdown-body table td {
    padding: 6px 13px;
    border: 1px solid var(--color-border);
}
.markdown-body table th {
    font-weight: 600;
    background: var(--color-bg-muted);
}
.markdown-body table tr:nth-child(2n) {
    background: var(--color-bg-muted);
}
.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background: var(--color-code-bg);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background: var(--color-bg-muted);
    border-radius: 6px;
}
.markdown-body pre code {
    padding: 0;
    background: transparent;
    border-radius: 0;
}
.markdown-body ul, .markdown-body ol {
    padding-left: 2em;
    margin-bottom: 16px;
}
.markdown-body li + li { margin-top: 4px; }
.markdown-body blockquote {
    padding: 0 1em;
    color: var(--color-blockquote);
    border-left: 0.25em solid var(--color-blockquote-border);
    margin: 0 0 16px;
}

/* SVG 图标颜色（配合 fill="currentColor"） */
.icon-dir { color: var(--color-icon-dir); }
.icon-file { color: var(--color-icon-file); }
.file-current .icon-file { color: var(--color-link); }

/* Dark 主题：文件表格链接默认文本色，hover 变蓝+下划线 */
[data-theme="dark"] .file-table a {
  color: var(--color-text);
}
[data-theme="dark"] .file-table a:hover {
  color: var(--color-link);
  text-decoration: underline;
}
[data-theme="dark"] .file-table-container {
  background: var(--color-iframe-bg);
}
[data-theme="dark"] .auth-card {
  background: var(--color-iframe-bg);
}
[data-theme="dark"] .chart-box {
  background: var(--color-iframe-bg);
}
[data-theme="dark"] .fund-chart-box {
  background: var(--color-iframe-bg);
}
[data-theme="dark"] .user-menu-dropdown {
  background: var(--color-iframe-bg);
}
[data-theme="dark"] .back-to-top {
  background: var(--color-iframe-bg);
}

/* === Theme Toggle === */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-header-muted);
  border-radius: 6px;
  color: var(--color-header-text);
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: border-color 0.2s;
}
.theme-toggle:hover {
  border-color: var(--color-header-text);
}

/* === Chart & Data Section === */
.chart-section {
  margin-bottom: 24px;
}
.chart-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--color-text);
}
.chart-box {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}
.data-table-details {
  margin-top: 8px;
}
.data-table-details summary {
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 4px 0;
}
.data-table-details summary:hover {
  color: var(--color-link);
}
.data-table-scroll {
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.browse-all-link {
  font-size: 14px;
  color: var(--color-link);
  text-decoration: none;
}
.browse-all-link:hover {
  text-decoration: underline;
}

/* === Header Right (theme + user menu) === */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === User Menu === */
.user-menu {
  position: relative;
}
.user-menu-btn {
  background: none;
  border: 1px solid var(--color-header-muted);
  border-radius: 6px;
  color: var(--color-header-text);
  cursor: pointer;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  transition: border-color 0.2s;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-btn:hover {
  border-color: var(--color-header-text);
}
.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 150px;
  z-index: 100;
  padding: 4px 0;
}
.user-menu-dropdown.open {
  display: block;
}
.user-menu-dropdown a {
  display: block;
  padding: 8px 16px;
  color: var(--color-text);
  font-size: 13px;
  text-decoration: none;
}
.user-menu-dropdown a:hover {
  background: var(--color-bg-muted);
  text-decoration: none;
}
.user-menu-dropdown hr {
  margin: 4px 0;
  border: none;
  border-top: 1px solid var(--color-border);
}

/* === Auth Forms === */
.auth-card {
  max-width: 400px;
  margin: 48px auto;
  padding: 32px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}
.auth-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
  text-align: center;
  color: var(--color-text);
}
.auth-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin: 0 0 16px;
  font-size: 14px;
}
.auth-form {
  display: flex;
  flex-direction: column;
}
.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
  margin-top: 12px;
}
.auth-label:first-of-type {
  margin-top: 0;
}
.auth-input {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}
.auth-input:focus {
  border-color: var(--color-link);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}
.auth-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.pw-wrapper {
  position: relative;
}
.pw-wrapper .auth-input {
  width: 100%;
  box-sizing: border-box;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
}
.pw-toggle:hover {
  color: var(--color-text);
}
.auth-btn {
  margin-top: 20px;
  padding: 10px 16px;
  background: var(--color-link);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.auth-btn:hover {
  opacity: 0.9;
}
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}
.flash-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.flash-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}
[data-theme="dark"] .flash-error {
  background: #2a1215;
  color: #f87171;
  border-color: #3d1f22;
}
[data-theme="dark"] .flash-success {
  background: #0f2a1e;
  color: #6ee7b7;
  border-color: #1a3d2e;
}
[data-theme="paper"] .flash-error {
  background: #fdf2e9;
  color: #b91c1c;
  border-color: #f0d5c0;
}
[data-theme="paper"] .flash-success {
  background: #f0f5e9;
  color: #15803d;
  border-color: #d5e0c0;
}

/* === Profile === */
.profile-info {
  margin-top: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--color-border);
}
.profile-info p {
  margin: 6px 0;
  font-size: 13px;
  color: var(--color-text-muted);
}
.profile-label {
  color: var(--color-text);
  font-weight: 600;
}

/* === Invite === */
.invite-notice {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}
.invite-link-row {
  display: flex;
  gap: 8px;
}
.invite-link-input {
  flex: 1;
  min-width: 0;
}
.invite-copy-btn {
  margin-top: 0;
  padding: 8px 16px;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}
.invite-copy-btn.copied {
  background: #16a34a;
  transform: scale(1.05);
}
[data-theme="dark"] .invite-copy-btn.copied {
  background: #6ee7b7;
}
[data-theme="paper"] .invite-copy-btn.copied {
  background: #15803d;
}
.invite-used {
  margin-top: 12px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* === Favorite Star === */
.favorite-star {
  cursor: pointer;
  color: var(--color-text-muted);
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
  margin-left: 8px;
  vertical-align: middle;
}
.favorite-star:hover {
  opacity: 0.8;
  color: #d4a017;
}
.favorite-star.active {
  opacity: 1;
  color: #d4a017;
}
.favorite-tooltip {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  animation: fadeOut 2s forwards;
}
@keyframes fadeOut {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* === USDA Balance Table === */
.balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.balance-table-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin: 16px 0;
}
.balance-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.balance-table th,
.balance-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
}
.balance-table th:last-child,
.balance-table td:last-child {
  border-right: none;
}
.balance-table thead th {
  background: var(--color-bg-muted);
  font-weight: 600;
}
.balance-year-col {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--color-bg);
  font-weight: 500;
  min-width: 72px;
  text-align: center;
  border-right: 2px solid var(--color-border) !important;
}
thead .balance-year-col {
  z-index: 3;
  background: var(--color-bg-muted);
}
.balance-unit-row td {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  font-size: 11px;
  text-align: center;
}
.balance-unit-row .balance-year-col {
  background: var(--color-bg-muted);
  position: -webkit-sticky;
  position: sticky;
  left: 0;
}
.balance-unit-cell {
  text-align: center;
}
.balance-attr-col {
  text-align: center;
  min-width: 80px;
}
.balance-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.btn-show-more {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-link);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-show-more:hover {
  background: var(--color-bg-muted);
}

/* === "上一级" Row Style === */
.file-table .row-parent td {
  color: var(--color-text-muted);
}
.file-table .row-parent .icon-dir {
  color: var(--color-text-muted);
}
.file-table .row-parent a {
  color: var(--color-text-muted);
}
.file-table .row-parent a:hover {
  color: var(--color-link);
}

/* === "显示更多" Button (block level) === */
.btn-show-more-block {
  display: block;
  margin: 12px auto;
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-link);
  cursor: pointer;
  font-size: 12px;
}
.btn-show-more-block:hover {
  background: var(--color-bg-muted);
}

/* === Dark Theme Scrollbar === */
[data-theme="dark"] {
  color-scheme: dark;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-muted);
}
::-webkit-scrollbar-thumb {
  background: var(--color-text-muted);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text);
}

/* === Mobile === */
@media (max-width: 768px) {
    html { scrollbar-gutter: auto; }
    .container { padding: 16px 12px; }
    .col-time { display: none; }
    th.col-time { display: none; }
    .col-desc { display: none; }
    th.col-desc { display: none; }
    .col-fav { display: none; }
    th.col-fav { display: none; }
    .file-table th,
    .file-table td { padding: 8px 12px; }
    .markdown-body { padding: 16px; }
    #report-frame,
    .file-frame-container iframe { height: 400px; }

    /* 全站 sticky tab + header 滚动隐藏 */
    .section-tabs {
        position: sticky;
        top: 0;
        z-index: 49;
    }
    .site-header {
        max-height: 60px;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease, border-width 0.3s ease;
    }
    .site-header.header-hidden {
        max-height: 0;
        border-bottom-width: 0;
    }
    .site-header.header-hidden .header-nav {
        padding-top: 0;
        padding-bottom: 0;
    }

    /* 聊天页固定布局 */
    body.page-chat {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    body.page-chat .site-header {
        flex-shrink: 0;
    }
    body.page-chat .section-tabs {
        flex-shrink: 0;
        position: relative;
    }
    body.page-chat .container {
        padding: 0;
        flex: 1;
        overflow: hidden;
        display: flex;
        min-height: 0;
    }
    body.page-chat .chat-container {
        width: 100%;
        height: auto;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    body.page-chat .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }
    body.page-chat .chat-input-area {
        flex-shrink: 0;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    }
    body.page-chat .back-to-top {
        display: none;
    }
}

/* === Back to Top === */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, color 0.15s, background 0.15s, box-shadow 0.15s;
  z-index: 100;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:hover {
  color: var(--color-text);
  background: var(--color-bg-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
[data-theme="dark"] .back-to-top {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .back-to-top:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* === Fund (资金流向) === */
.fund-section {
  margin-bottom: 28px;
}
.fund-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.fund-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}
.fund-section-sub {
  font-size: 12px;
  color: var(--color-text-muted);
}
.fund-card {
  background: var(--fund-card-bg);
  border: 1px solid var(--fund-card-border);
  border-radius: 8px;
  padding: 16px 20px;
}
.fund-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.fund-metrics-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.fund-metric-card {
  background: var(--fund-card-bg);
  border: 1px solid var(--fund-card-border);
  border-radius: 8px;
  padding: 14px 16px;
}
.fund-metric-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.fund-metric-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.fund-metric-value.positive { color: var(--fund-positive); }
.fund-metric-value.negative { color: var(--fund-negative); }
.fund-metric-streak {
  font-size: 11px;
  margin-top: 2px;
  color: var(--color-text-muted);
}
.fund-metric-change {
  font-size: 12px;
  margin-top: 2px;
  color: var(--color-text-muted);
}
.fund-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.fund-tabs::-webkit-scrollbar { display: none; }
.fund-tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  white-space: nowrap;
}
.fund-tab:hover { color: var(--color-text); }
.fund-tab.active {
  color: var(--color-text);
  font-weight: 600;
  border-bottom-color: var(--color-link);
}
.fund-tab-content { display: none; }
.fund-tab-content.active { display: block; }
.fund-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fund-table th {
  background: var(--color-bg-muted);
  font-weight: 600;
  font-size: 12px;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.fund-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.fund-table tbody tr:last-child td { border-bottom: none; }
.fund-table tbody tr:hover { background: var(--color-bg-muted); }
.fund-table .col-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fund-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.fund-chart-box {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  padding: 4px;
}
.fund-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.fund-tag-in { background: rgba(22, 163, 74, 0.1); color: var(--fund-negative); }
.fund-tag-out { background: rgba(220, 38, 38, 0.1); color: var(--fund-positive); }
.fund-tag-hold { background: var(--color-bg-muted); color: var(--color-text-muted); }
[data-theme="dark"] .fund-tag-in { background: rgba(110, 231, 183, 0.15); }
[data-theme="dark"] .fund-tag-out { background: rgba(248, 113, 113, 0.15); }
.fund-empty {
  text-align: center;
  padding: 32px;
  color: var(--color-text-muted);
  font-size: 14px;
}
.fund-highlight-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 12px;
}
.fund-highlight-val {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.fund-highlight-label {
  font-size: 13px;
  color: var(--color-text-muted);
}
/* === 配置全景卡片 === */
.fund-overview-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.fund-overview-card {
  background: var(--fund-card-bg);
  border: 1px solid var(--fund-card-border);
  border-radius: 8px;
  padding: 14px 16px;
}
.fund-overview-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 4px 0 2px;
}
.fund-overview-change {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
}
.fund-overview-change.positive { color: var(--fund-positive); }
.fund-overview-change.negative { color: var(--fund-negative); }
.fund-overview-arrow { margin-right: 2px; }
.fund-overview-tag {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg-muted);
  padding: 1px 8px;
  border-radius: 12px;
}
/* === 时间线 === */
.fund-timeline { position: relative; }
.fund-timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}
.fund-timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--color-border);
}
.fund-timeline-item:last-child { padding-bottom: 0; }
.fund-timeline-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--color-link);
  flex-shrink: 0;
  margin-top: 3px;
}
.fund-timeline-dot.dot-tic { background: #f87171; }
.fund-timeline-dot.dot-ipo { background: #fbbf24; }
.fund-timeline-dot.dot-sec { background: #a78bfa; }
.fund-timeline-date {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.fund-timeline-text {
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.4;
}
/* fund sub-navigation */
.fund-sub-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.fund-sub-nav-item {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  transition: all 0.15s;
}
.fund-sub-nav-item:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}
.fund-sub-nav-item.active {
  color: #fff;
  background: var(--color-link);
  border-color: var(--color-link);
}

/* fund rank — 期货排名页色系（中国习惯：涨红跌绿） */
.rank-positive { color: var(--fund-positive) !important; }  /* 净多增=红 */
.rank-negative { color: var(--fund-negative) !important; }  /* 净空增=绿 */

/* 品种详情 — 三列排名 */
.rank-three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.rank-col-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--color-text); }
.fund-table-compact { font-size: 12px; }
.fund-table-compact th, .fund-table-compact td { padding: 3px 6px; }

/* 新进/退出标签 */
.rank-tag { display: inline-block; font-size: 10px; padding: 1px 4px; border-radius: 3px; margin-left: 4px; vertical-align: middle; }
.rank-tag-new { background: var(--fund-negative); color: #fff; }
.rank-tag-danger { background: var(--fund-positive); color: #fff; }
.rank-tag-warn { background: #e8a838; color: #fff; }

/* 联动分析行高亮 */
.rank-row-danger { background: rgba(255, 77, 79, 0.08); }
.rank-row-warn { background: rgba(232, 168, 56, 0.06); }

/* Tab 切换按钮 */
.fund-tab-btn {
  background: var(--color-bg-elevated); color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: 6px;
  padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.fund-tab-btn.active {
  background: var(--fund-accent, #5470c6); color: #fff;
  border-color: var(--fund-accent, #5470c6);
}

@media (max-width: 768px) {
  .fund-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .fund-two-col { grid-template-columns: 1fr; }
  .fund-overview-cards { grid-template-columns: 1fr 1fr; }
  .fund-card { overflow-x: auto; }
  .fund-metric-card { overflow: hidden; }
  .fund-metric-value { font-size: 16px; }
  .fund-overview-val { font-size: 16px; }
  .rank-three-col { grid-template-columns: 1fr; }
}

/* === Chat — 小玉助手 === */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
}

.chat-disabled {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--color-text-muted);
  font-size: 16px;
}

/* header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.chat-header-left { display: flex; align-items: baseline; gap: 8px; }
.chat-title { margin: 0; font-size: 18px; font-weight: 600; }
.chat-subtitle { color: var(--color-text-muted); font-size: 13px; }
.chat-action-btn {
  background: none; border: 1px solid var(--color-border); border-radius: 6px;
  color: var(--color-text-muted); padding: 4px 8px; cursor: pointer;
}
.chat-action-btn:hover { color: var(--color-text); border-color: var(--color-text-muted); }

/* messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}

/* welcome */
.chat-welcome {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
}
.chat-welcome-icon { font-size: 40px; margin-bottom: 12px; }
.chat-welcome h3 { margin: 0 0 8px; color: var(--color-text); font-size: 20px; }
.chat-welcome p { margin: 0 0 24px; font-size: 14px; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chat-suggestion {
  background: var(--color-bg-muted); border: 1px solid var(--color-border);
  border-radius: 16px; padding: 6px 14px; font-size: 13px;
  color: var(--color-text); cursor: pointer; transition: background 0.15s;
}
.chat-suggestion:hover { background: var(--color-bg-highlight); }
.chat-suggestions-row { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chat-refresh-btn {
  background: none; border: 1px solid var(--color-border); border-radius: 12px;
  padding: 4px 10px; font-size: 12px; color: var(--color-text-secondary);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.chat-refresh-btn:hover { background: var(--color-bg-highlight); color: var(--color-text); }

/* header actions (subscription icons + clear) */
.chat-header-actions { display: flex; align-items: center; gap: 6px; }
.chat-sub-icon-btn {
  position: relative; transition: all 0.2s;
}
.chat-sub-icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-sub-icon-btn.chat-sub-active {
  background: var(--color-bg-highlight); border-color: var(--color-link); color: var(--color-link);
}

/* message bubbles */
.chat-msg { display: flex; margin-bottom: 12px; max-width: 100%; overflow: hidden; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }
.chat-bubble {
  max-width: 80%;
  min-width: 0;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
  overflow: hidden;
}
.chat-msg-user .chat-bubble {
  background: var(--color-link);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-bubble {
  background: var(--color-bg-muted);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

/* typing indicator */
.chat-typing::after {
  content: '▌';
  animation: chat-blink 0.8s infinite;
}
@keyframes chat-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* video progress bar */
.chat-progress { padding: 8px 0 4px; }
.chat-progress-bar {
  width: 100%; height: 8px;
  background: var(--color-bg-muted); border-radius: 4px;
  overflow: hidden; margin-bottom: 6px;
}
.chat-progress-fill {
  display: block; height: 100%;
  background: var(--color-link); border-radius: 4px;
  transition: width 0.6s ease;
}
.chat-progress-fill.chat-progress-active {
  background-image: linear-gradient(
    -45deg,
    rgba(255,255,255,.2) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,.2) 50%,
    rgba(255,255,255,.2) 75%, transparent 75%
  );
  background-size: 16px 16px;
  animation: progress-stripe 0.6s linear infinite;
}
@keyframes progress-stripe {
  from { background-position: 16px 0; }
  to   { background-position: 0 0; }
}
.chat-progress-text { font-size: 0.85em; color: var(--color-text-muted); margin-top: 2px; }

/* error text */
.chat-error { color: #dc2626; }
[data-theme="dark"] .chat-error,
[data-theme="fund"] .chat-error { color: #f87171; }

.chat-msg-content { min-width: 0; max-width: 100%; overflow: hidden; }

/* chat table */
.chat-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; }
.chat-table { border-collapse: separate; border-spacing: 0; font-size: 12px; white-space: nowrap; }
.chat-table th, .chat-table td { border: 1px solid var(--color-border, #d0d7de); padding: 4px 8px; text-align: left; }
.chat-table th { background: var(--color-bg-muted, #f6f8fa); font-weight: 600; }
.chat-table tr:nth-child(even) td { background: var(--color-bg-subtle, #f6f8fa22); }
[data-theme="dark"] .chat-table th { background: #1c1d28; }
[data-theme="dark"] .chat-table td { border-color: #2d2e3d; }
[data-theme="dark"] .chat-table tr:nth-child(even) td { background: #14151e; }

/* delete button on bubble */
.chat-msg-delete {
  position: absolute; top: 2px; right: 4px;
  background: none; border: none; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px;
  color: transparent; transition: color 0.15s;
}
.chat-bubble:hover .chat-msg-delete { color: var(--color-text-muted); }
.chat-msg-delete:hover { color: var(--color-text); }
.chat-msg-user .chat-msg-delete:hover { color: rgba(255,255,255,0.8); }
.chat-msg-user .chat-bubble:hover .chat-msg-delete { color: rgba(255,255,255,0.5); }

/* code in assistant messages */
.chat-msg-content pre {
  background: var(--color-code-bg); border-radius: 6px;
  padding: 8px 12px; overflow-x: auto; font-size: 13px; margin: 6px 0;
}
.chat-msg-content code {
  background: var(--color-code-bg); padding: 1px 4px; border-radius: 3px; font-size: 13px;
}
.chat-msg-content pre code { background: none; padding: 0; }
.chat-msg-content a {
  color: var(--color-link); text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-msg-content a:hover { opacity: 0.8; }

/* broadcast card styles */
.broadcast { padding: 2px 0; }
.broadcast-header {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
.broadcast-icon { font-size: 24px; flex-shrink: 0; }
.broadcast-title { font-weight: 600; font-size: 15px; color: var(--color-text); }
.broadcast-meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.broadcast-section-title {
  font-weight: 600; font-size: 13px; color: var(--color-link);
  margin: 14px 0 8px; padding-left: 10px;
  border-left: 3px solid var(--color-link);
}
.broadcast-card {
  background: var(--color-bg-muted); border: 1px solid var(--color-border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.broadcast-source {
  display: inline-block; font-size: 11px; font-weight: 500;
  background: var(--color-bg-highlight); color: var(--color-text-muted);
  padding: 1px 8px; border-radius: 10px; margin-bottom: 6px;
}
.broadcast-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--color-text); }
.broadcast-card-summary { font-size: 13px; line-height: 1.6; color: var(--color-text-secondary); }
.broadcast-link {
  display: inline-block; margin-top: 6px; font-size: 12px;
  color: var(--color-link); text-decoration: none;
}
.broadcast-link:hover { text-decoration: underline; }

/* broadcast inline action buttons */
.chat-action-buttons { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chat-inline-btn {
  padding: 6px 16px; border-radius: 16px; font-size: 13px;
  cursor: pointer; border: 1px solid var(--color-border); transition: all 0.15s;
}
.chat-inline-btn-primary {
  background: var(--color-link); color: #fff; border-color: var(--color-link);
}
.chat-inline-btn-primary:hover { opacity: 0.85; }
.chat-inline-btn-secondary {
  background: var(--color-bg-muted); color: var(--color-text-muted);
}
.chat-inline-btn-secondary:hover { background: var(--color-bg-highlight); }

/* dark theme broadcast overrides */
[data-theme="dark"] .broadcast-card { background: #1a1b26; border-color: #252636; }
[data-theme="dark"] .broadcast-source { background: #252636; color: #8b8d9e; }
[data-theme="dark"] .chat-inline-btn-secondary { background: #1a1b26; border-color: #252636; color: #8b8d9e; }

/* paper theme broadcast overrides */
[data-theme="paper"] .broadcast-card { background: #f3ede4; border-color: #e0d5c4; }
[data-theme="paper"] .broadcast-source { background: #e0d5c4; color: #8a7e6b; }

/* input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  max-width: 100%;
  box-sizing: border-box;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.chat-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  min-height: 38px;
  max-height: 120px;
  font-family: inherit;
}
.chat-input-area textarea:focus { border-color: var(--color-link); }
.chat-send-btn {
  background: var(--color-link); color: #fff; border: none; border-radius: 50%;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.85; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* dark theme overrides */
[data-theme="dark"] .chat-msg-user .chat-bubble {
  background: #2d6a4f;
  color: #e8e6e1;
}
[data-theme="dark"] .chat-msg-assistant .chat-bubble {
  background: #14151e;
}
[data-theme="dark"] .chat-suggestion {
  background: #14151e;
  border-color: #252636;
}
[data-theme="dark"] .chat-suggestion:hover { background: #1c1d28; }
[data-theme="dark"] .chat-refresh-btn { border-color: #252636; color: #8b8d9e; }
[data-theme="dark"] .chat-refresh-btn:hover { background: #1c1d28; color: #c5c7d5; }

/* paper theme */
[data-theme="paper"] .chat-msg-user .chat-bubble {
  background: #8b5e3c;
}

/* mic button */
.chat-mic-btn {
  background: none; border: 1px solid var(--color-border); border-radius: 50%;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; color: var(--color-text-muted); transition: all 0.2s;
}
.chat-mic-btn:hover { color: var(--color-text); border-color: var(--color-text-muted); }
.chat-mic-recording {
  color: #dc2626; border-color: #dc2626; background: rgba(220,38,38,0.08);
  animation: chat-mic-pulse 1.2s infinite;
}
@keyframes chat-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
.chat-mic-processing {
  color: var(--color-link); border-color: var(--color-link);
  animation: chat-mic-spin 1s linear infinite;
}
@keyframes chat-mic-spin {
  100% { transform: rotate(360deg); }
}

/* TTS play button on assistant bubbles */
.chat-tts-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); padding: 4px; margin-top: 4px;
  border-radius: 4px; transition: color 0.15s;
}
.chat-tts-btn:hover { color: var(--color-text); }
.chat-tts-loading { opacity: 0.7; cursor: wait; }
.chat-tts-playing { color: var(--color-link); }

/* TTS loading indicator */
.chat-tts-indicator {
  display: inline-block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: 6px;
  vertical-align: middle;
}
.tts-dots span {
  animation: tts-dot-blink 1.4s infinite;
  opacity: 0;
}
.tts-dots span:nth-child(1) { animation-delay: 0s; }
.tts-dots span:nth-child(2) { animation-delay: 0.3s; }
.tts-dots span:nth-child(3) { animation-delay: 0.6s; }
@keyframes tts-dot-blink {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

/* TTS playing wave animation */
.chat-tts-playing .tts-wave-inner {
  animation: tts-wave-pulse 1.2s ease-in-out infinite;
}
.chat-tts-playing .tts-wave-outer {
  animation: tts-wave-pulse 1.2s ease-in-out infinite 0.3s;
}
@keyframes tts-wave-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
[data-theme="dark"] .chat-tts-btn { color: #8b949e; }
[data-theme="dark"] .chat-tts-btn:hover { color: #e8e6e1; }
[data-theme="dark"] .chat-tts-playing { color: #6ee7b7; }
[data-theme="dark"] .chat-mic-btn { border-color: #252636; color: #8b949e; }
[data-theme="dark"] .chat-mic-btn:hover { color: #e8e6e1; border-color: #8b949e; }

/* mobile */
@media (max-width: 768px) {
  .chat-container { height: calc(100vh - 110px); }
  .chat-bubble { max-width: 90%; }
  .chat-suggestions { flex-direction: column; align-items: center; }
  .chat-suggestions-row { flex-direction: column; }
  .chat-input-area textarea { font-size: 16px; }
  /* 表格：第一列 sticky，容器强制约束 */
  .chat-table-wrap { max-width: calc(100vw - 90px); }
  .chat-table th:first-child,
  .chat-table td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--color-bg-muted, #f6f8fa);
    border-right: 2px solid var(--color-border, #d0d7de);
  }
  .chat-table td:first-child { background: var(--color-bg, #fff); }
  [data-theme="dark"] .chat-table th:first-child { background: #1c1d28; }
  [data-theme="dark"] .chat-table td:first-child { background: #0d1117; }
  [data-theme="paper"] .chat-table th:first-child { background: #f0ead6; }
  [data-theme="paper"] .chat-table td:first-child { background: #faf6eb; }
}

/* ── 播报可折叠卡片 ─────────────────────── */
.broadcast-collapsible-wrap {
  position: relative;
}
.broadcast-collapsible {
  max-height: 280px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.broadcast-expanded .broadcast-collapsible {
  max-height: none;
}
.broadcast-fade {
  height: 60px;
  margin-top: -60px;
  background: linear-gradient(transparent, var(--color-bg-muted, #f6f8fa));
  pointer-events: none;
}
.broadcast-expand-btn {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: center;
  background: var(--color-bg-muted, #f5f5f5);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-link, #4a8);
  margin-top: 4px;
}
.broadcast-expand-btn:hover {
  opacity: 0.8;
}
[data-theme="dark"] .broadcast-fade {
  background: linear-gradient(transparent, #14151e);
}
[data-theme="dark"] .broadcast-expand-btn {
  background: #1a1b26;
  border-color: #252636;
  color: #6ee7b7;
}
[data-theme="paper"] .broadcast-fade {
  background: linear-gradient(transparent, #f3ede4);
}
[data-theme="paper"] .broadcast-expand-btn {
  background: #f3ede4;
  border-color: #e0d5c4;
  color: #8b5e3c;
}
