/* XCMDY Studio LLM-API —— Google / Trae 融合设计系统
   设计规范：
   - Google 主蓝 #1a73e8 强调色 + 柔和圆角（8/12/16/24/9999px）+ 低饱和语义容器
   - Trae 侧边导航（260px）+ 64px 顶栏 + 滚动内容画布
   - Google Sans 字体栈，全部组件纯手写 CSS，无外部依赖
*/

:root {
  /* 语义映射 */
  --background: #FFFFFF;
  --foreground: #202124;
  --card: #FFFFFF;
  --card-foreground: #202124;
  --primary: #1a73e8;
  --primary-foreground: #FFFFFF;
  --secondary: #F0F4F9;
  --secondary-foreground: #1967d2;
  --muted: #F8F9FA;
  --muted-foreground: #5F6368;
  --accent: #E8F0FE;
  --accent-foreground: #1967d2;
  --destructive: #EA4335;
  --destructive-foreground: #FFFFFF;
  --border: #E0E2E6;
  --input: #E0E2E6;
  --ring: #1a73e8;

  /* Google 品牌色 */
  --google-blue: #1a73e8;
  --google-blue-hover: #1557b0;
  --google-blue-container: #e8f0fe;
  --google-blue-text: #1967d2;
  --google-red: #ea4335;
  --google-red-container: #fce8e6;
  --google-yellow: #fbbc04;
  --google-yellow-container: #fef7e0;
  --google-green: #34a853;
  --google-green-container: #e6f4ea;

  /* 表面与层级 */
  --bg-base-default: #FFFFFF;
  --bg-base-secondary: #F8F9FA;
  --bg-base-tertiary: #F1F3F4;
  --bg-surface-elevated: #FFFFFF;
  --bg-surface-tinted: #F0F4F9;
  --bg-overlay-l1: rgba(32, 33, 36, 0.04);
  --bg-overlay-l2: rgba(32, 33, 36, 0.08);
  --bg-overlay-l3: rgba(32, 33, 36, 0.12);

  /* 字体 */
  --font-family-default: "Google Sans", "SF Pro Text", "PingFang SC", "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
  --font-family-heading: "Google Sans Display", "Google Sans", "SF Pro", "PingFang SC", sans-serif;
  --font-family-metric: "Google Sans Text", "Inter", system-ui, sans-serif;
  --font-family-mono: "Google Sans Mono", "JetBrains Mono", "SF Mono", Consolas, monospace;

  /* 文字 */
  --text-default: #202124;
  --text-secondary: #5F6368;
  --text-tertiary: #80868B;
  --text-disabled: #BDC1C6;
  --text-onbrand: #FFFFFF;

  /* 间距 */
  --spacer-2: 2px;
  --spacer-4: 4px;
  --spacer-6: 6px;
  --spacer-8: 8px;
  --spacer-12: 12px;
  --spacer-16: 16px;
  --spacer-20: 20px;
  --spacer-24: 24px;
  --spacer-32: 32px;
  --spacer-40: 40px;
  --spacer-48: 48px;

  /* 圆角 */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* 边框与阴影 */
  --border-neutral-l1: #E0E2E6;
  --border-neutral-l2: #D2D6DC;
  --border-focus: var(--google-blue);
  --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-md: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  --shadow-lg: 0 2px 6px 2px rgba(60, 64, 67, 0.15), 0 8px 24px 4px rgba(60, 64, 67, 0.12);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.08);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-family-default);
  background-color: var(--bg-base-secondary);
  color: var(--text-default);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--google-blue);
  text-decoration: none;
}
a:hover {
  color: var(--google-blue-hover);
  text-decoration: underline;
}

code, pre, .mono {
  font-family: var(--font-family-mono);
}

/* ---------- 通用工具类 ---------- */
.hidden { display: none !important; }
.small { font-size: 12px; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.num { text-align: right; }
.mono { font-family: var(--font-family-mono); }

/* ---------- App Shell 骨架 ---------- */
.tg-app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* 侧栏遮罩层（手机端/移动端抽屉） */
.tg-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(32, 33, 36, 0.45);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.tg-nav-overlay.open {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

/* ---------- 左侧导航栏 ---------- */
.tg-nav-rail {
  width: 260px;
  background: var(--bg-base-default);
  border-right: 1px solid var(--border-neutral-l1);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tg-nav-header {
  height: 64px;
  padding: 0 var(--spacer-20);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacer-12);
  border-bottom: 1px solid var(--border-neutral-l1);
}

.tg-nav-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-full);
}
.tg-nav-close:hover {
  background: var(--bg-surface-tinted);
  color: var(--text-default);
}

.tg-brand-badge {
  display: flex;
  align-items: center;
  gap: var(--spacer-12);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-default);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--google-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(26, 115, 232, 0.4);
}

.tg-brand-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tg-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-default);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-brand-tag {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  line-height: 1.2;
}

.tg-nav-body {
  flex: 1;
  padding: var(--spacer-16) var(--spacer-12);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacer-24);
}

.tg-nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 0 var(--spacer-12) var(--spacer-6);
}

.tg-nav-menu {
  display: flex;
  flex-direction: column;
  gap: var(--spacer-4);
}

.tg-nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacer-12);
  padding: 10px var(--spacer-16);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.tg-nav-item:hover {
  background: var(--bg-surface-tinted);
  color: var(--text-default);
  text-decoration: none;
}

.tg-nav-item.active {
  background: var(--google-blue-container);
  color: var(--google-blue-text);
  font-weight: 600;
}

.tg-nav-item.active svg, .tg-nav-item.active .tg-nav-icon {
  color: var(--google-blue);
}

.tg-nav-item svg, .tg-nav-item .tg-nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.tg-nav-foot {
  padding: var(--spacer-12);
  border-top: 1px solid var(--border-neutral-l1);
}

/* ---------- 主区域包裹 ---------- */
.tg-main-wrap, .tg-main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-base-secondary);
  min-width: 0;
}

/* ---------- 顶栏 ---------- */
.tg-top-bar {
  height: 64px;
  background: var(--bg-base-default);
  border-bottom: 1px solid var(--border-neutral-l1);
  padding: 0 var(--spacer-32);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacer-16);
  flex-shrink: 0;
  z-index: 10;
}

.tg-top-left {
  display: flex;
  align-items: center;
  gap: var(--spacer-12);
  min-width: 0;
}

/* 汉堡菜单按钮 (默认桌面隐藏，移动端显示) */
.tg-hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-neutral-l1);
  color: var(--text-default);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.tg-hamburger-btn:hover {
  background: var(--bg-surface-tinted);
  border-color: var(--border-neutral-l2);
}

.tg-top-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-default);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-top-actions {
  display: flex;
  align-items: center;
  gap: var(--spacer-12);
  flex-shrink: 0;
}

.tg-user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--spacer-8);
  padding: 5px var(--spacer-12);
  border-radius: var(--radius-full);
  background: var(--bg-surface-tinted);
  border: 1px solid var(--border-neutral-l1);
  color: var(--text-default);
  font-size: 13px;
  font-weight: 500;
}

.tg-user-chip .dot {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--google-blue), var(--google-green));
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- 滚动内容区 ---------- */
.tg-scroll-canvas {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacer-32);
}

.tg-page-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacer-32);
}

/* 视图切换 */
.tg-view {
  display: none;
  flex-direction: column;
  gap: var(--spacer-24);
}

.tg-view.active {
  display: flex;
}

/* ---------- 按钮 ---------- */
.tg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacer-8);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  padding: 8px var(--spacer-16);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  line-height: 20px;
  text-decoration: none;
  color: var(--text-default);
}

.tg-btn:hover {
  text-decoration: none;
}

.tg-btn-primary {
  background: var(--google-blue);
  color: #FFFFFF;
}
.tg-btn-primary:hover {
  background: var(--google-blue-hover);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.tg-btn-tonal {
  background: var(--google-blue-container);
  color: var(--google-blue-text);
}
.tg-btn-tonal:hover {
  background: #d3e3fd;
  color: var(--google-blue-text);
}

.tg-btn-outlined {
  background: transparent;
  border-color: var(--border-neutral-l1);
  color: var(--text-secondary);
}
.tg-btn-outlined:hover {
  background: var(--bg-overlay-l1);
  color: var(--text-default);
  border-color: var(--border-neutral-l2);
}

.tg-btn-danger {
  background: var(--google-red-container);
  color: var(--google-red);
}
.tg-btn-danger:hover {
  background: #f9d4d0;
  color: #c5221f;
}

.tg-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.tg-btn-ghost:hover {
  background: var(--bg-surface-tinted);
  color: var(--text-default);
}

.tg-btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.tg-btn-icon:hover {
  background: var(--bg-surface-tinted);
  color: var(--text-default);
}

.tg-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 链接型操作按钮（表格内） */
.tg-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--google-blue);
  cursor: pointer;
  text-decoration: none;
}
.tg-link-btn:hover {
  color: var(--google-blue-hover);
  text-decoration: underline;
}
.tg-link-btn.danger {
  color: var(--google-red);
}
.tg-link-btn.danger:hover {
  color: #c5221f;
}

/* ---------- 卡片 ---------- */
.tg-card {
  background: var(--bg-base-default);
  border: 1px solid var(--border-neutral-l1);
  border-radius: var(--radius-xl);
  padding: var(--spacer-24);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacer-12);
  margin-bottom: var(--spacer-16);
  flex-wrap: wrap;
}

.tg-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-default);
  display: flex;
  align-items: center;
  gap: var(--spacer-8);
}

.tg-card-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---------- 网格 ---------- */
.tg-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacer-24);
}

.tg-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacer-24);
}

.tg-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacer-24);
}

.tg-grid-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--spacer-24);
}

.tg-grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--spacer-24);
}

/* ---------- Hero 横幅 ---------- */
.tg-hero-banner {
  background: linear-gradient(135deg, #FFFFFF 0%, #F0F4F9 100%);
  border: 1px solid var(--border-neutral-l1);
  border-radius: var(--radius-2xl);
  padding: var(--spacer-32) var(--spacer-40);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacer-24);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.tg-hero-title {
  font-family: var(--font-family-heading);
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  color: var(--text-default);
  letter-spacing: -0.02em;
  margin-bottom: var(--spacer-6);
}

.tg-hero-desc {
  font-size: 14px;
  line-height: 22px;
  color: var(--text-secondary);
}

.tg-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacer-8);
}

/* ---------- 指标卡 ---------- */
.tg-metric-card {
  padding: var(--spacer-20);
  border-radius: var(--radius-lg);
  background: var(--bg-base-default);
  border: 1px solid var(--border-neutral-l1);
  display: flex;
  flex-direction: column;
  gap: var(--spacer-8);
  min-width: 0;
}

.tg-metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacer-8);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.tg-metric-val {
  font-family: var(--font-family-metric);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-default);
  line-height: 34px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-metric-foot {
  font-size: 12px;
  color: var(--text-tertiary);
  min-height: 16px;
}

/* ---------- 徽章 ---------- */
.tg-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacer-4);
  padding: 2px var(--spacer-8);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tg-badge-success {
  background: var(--google-green-container);
  color: var(--google-green);
}

.tg-badge-blue {
  background: var(--google-blue-container);
  color: var(--google-blue-text);
}

.tg-badge-warning {
  background: var(--google-yellow-container);
  color: #B06000;
}

.tg-badge-neutral {
  background: var(--bg-base-tertiary);
  color: var(--text-secondary);
}

.tg-badge-danger {
  background: var(--google-red-container);
  color: var(--google-red);
}

/* ---------- 表单 ---------- */
.tg-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacer-6);
}

.tg-form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tg-input {
  padding: 10px var(--spacer-16);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-neutral-l1);
  background: var(--bg-base-default);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-default);
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tg-input:focus {
  border-color: var(--google-blue);
  box-shadow: 0 0 0 3px var(--google-blue-container);
}

.tg-input::placeholder {
  color: var(--text-disabled);
}

select.tg-input {
  cursor: pointer;
}

textarea.tg-input {
  resize: vertical;
  line-height: 20px;
}

.tg-form-error {
  color: var(--google-red);
  font-size: 13px;
  min-height: 18px;
  margin: var(--spacer-4) 0;
}

.tg-form-note {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--spacer-6);
  padding: var(--spacer-8) var(--spacer-12);
  background: var(--google-yellow-container);
  color: #7a5200;
  border-radius: var(--radius-sm);
  margin-top: var(--spacer-8);
}

/* ---------- 开关 ---------- */
.tg-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.tg-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tg-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-neutral-l2);
  transition: .3s;
  border-radius: 24px;
}

.tg-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  transition: .3s;
  border-radius: 50%;
}

.tg-switch input:checked + .tg-slider {
  background-color: var(--google-blue);
}

.tg-switch input:checked + .tg-slider:before {
  transform: translateX(20px);
}

/* ---------- 代码块 ---------- */
.tg-code-box {
  background: #1E1F22;
  border-radius: var(--radius-md);
  padding: var(--spacer-16);
  color: #E2E8F0;
  font-family: var(--font-family-mono);
  font-size: 13px;
  line-height: 20px;
  overflow-x: auto;
  border: 1px solid #2D3748;
  white-space: pre;
}

code.tg-inline {
  background: var(--google-blue-container);
  color: var(--google-blue-text);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  font-size: 12.5px;
  font-family: var(--font-family-mono);
  word-break: break-all;
}

/* ---------- 表格 ---------- */
.tg-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.fusion-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.fusion-table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-neutral-l1);
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.fusion-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-neutral-l1);
  color: var(--text-default);
  vertical-align: middle;
  word-break: break-all;
}

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

.fusion-table tbody tr:hover td {
  background: var(--bg-surface-tinted);
}

.fusion-table td.num, .fusion-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.fusion-table .cell-empty {
  text-align: center;
  color: var(--text-tertiary);
  padding: 24px 16px !important;
}

/* ---------- API Key 展示 ---------- */
.tg-keyline {
  display: flex;
  align-items: center;
  gap: var(--spacer-8);
  background: var(--bg-base-secondary);
  border: 1px solid var(--border-neutral-l1);
  border-radius: var(--radius-sm);
  padding: 12px var(--spacer-16);
  font-family: var(--font-family-mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--text-default);
}

.tg-keyline .keytext {
  flex: 1;
  min-width: 0;
}

/* ---------- 配额进度条 ---------- */
.tg-quota {
  display: flex;
  flex-direction: column;
  gap: var(--spacer-6);
}

.tg-quota-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacer-8);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-default);
}

.tg-quota-caption .val {
  font-family: var(--font-family-metric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tg-progress {
  height: 8px;
  background: var(--bg-base-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.tg-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--google-blue), #4285f4);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tg-progress-fill.warn {
  background: linear-gradient(90deg, var(--google-yellow), #f9ab00);
}

.tg-progress-fill.danger {
  background: linear-gradient(90deg, var(--google-red), #ea4335);
}

.tg-quota-foot {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---------- 公告条 ---------- */
.tg-announcement {
  display: flex;
  align-items: center;
  gap: var(--spacer-8);
  background: var(--google-yellow-container);
  color: #7a5200;
  font-size: 13px;
  padding: var(--spacer-8) var(--spacer-16);
  border-radius: var(--radius-sm);
  border: 1px solid #f6dfa8;
}

.tg-announcement svg {
  flex-shrink: 0;
}

/* ---------- 聊天面板 ---------- */
.tg-chat-log {
  background: var(--bg-base-secondary);
  border: 1px solid var(--border-neutral-l1);
  border-radius: var(--radius-md);
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  padding: var(--spacer-16);
  display: flex;
  flex-direction: column;
  gap: var(--spacer-12);
}

.tg-chat-empty {
  color: var(--text-tertiary);
  text-align: center;
  padding: 48px 0;
  font-size: 13px;
}

.tg-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.tg-chat-msg .who {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: var(--spacer-4);
}

.tg-chat-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.tg-chat-msg.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.tg-chat-msg .bubble {
  padding: 10px var(--spacer-16);
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-base-default);
  border: 1px solid var(--border-neutral-l1);
}

.tg-chat-msg.user .bubble {
  background: var(--google-blue);
  color: #FFFFFF;
  border: none;
  border-bottom-right-radius: var(--radius-xs);
}

.tg-chat-msg.bot .bubble {
  border-bottom-left-radius: var(--radius-xs);
}

.tg-chat-msg .bubble.error {
  background: var(--google-red-container);
  color: #c5221f;
  border: 1px solid #f3b6b0;
}

.tg-chat-input {
  display: flex;
  gap: var(--spacer-12);
  align-items: flex-end;
  margin-top: var(--spacer-12);
}

.tg-chat-input textarea {
  flex: 1;
}

/* ---------- 弹窗 ---------- */
.tg-modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(32, 33, 36, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--spacer-16);
}

.tg-modal {
  background: var(--bg-base-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tg-modal-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacer-12);
  padding: var(--spacer-20) var(--spacer-24);
  border-bottom: 1px solid var(--border-neutral-l1);
}

.tg-modal-h h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-default);
}

.tg-modal-b {
  padding: var(--spacer-24);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacer-12);
}

/* ---------- 自写确认/提示对话框 (完全替代原生 confirm / alert) ---------- */
.tg-dialog-backdrop {
  z-index: 300;
}

.tg-dialog {
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.tg-dialog-title {
  padding: var(--spacer-20) var(--spacer-24);
  border-bottom: 1px solid var(--border-neutral-l1);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-default);
}

.tg-dialog-body {
  padding: var(--spacer-24);
  font-size: 14px;
  line-height: 22px;
  color: var(--text-default);
  word-break: break-word;
  white-space: pre-wrap;
}

.tg-dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--spacer-8);
  padding: 0 var(--spacer-24) var(--spacer-20);
}

/* ---------- 自写下拉选择框 (完全替代原生 <select>) ---------- */
.tg-cs {
  position: relative;
  display: inline-block;
  width: 100%;
  vertical-align: middle;
}

.tg-cs-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  border: 0;
  margin: 0;
  padding: 0;
}

.tg-cs-btn {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacer-8);
  padding: 10px var(--spacer-16);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-neutral-l1);
  background: var(--bg-base-default);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-default);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

.tg-cs.btn-open, .tg-cs-btn:focus {
  border-color: var(--google-blue);
  box-shadow: 0 0 0 3px var(--google-blue-container);
  outline: none;
}

.tg-cs-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-cs-arrow {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 12px;
  transition: transform 0.2s ease;
}

.tg-cs.btn-open .tg-cs-arrow {
  transform: rotate(180deg);
}

.tg-cs-menu {
  box-sizing: border-box;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 320;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-base-default);
  border: 1px solid var(--border-neutral-l1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--spacer-6);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  visibility: hidden;
}

.tg-cs.btn-open .tg-cs-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.tg-cs-item {
  padding: 9px var(--spacer-12);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-default);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-cs-item:hover {
  background: var(--bg-overlay-l1);
}

.tg-cs-item.active {
  background: var(--google-blue-container);
  color: var(--google-blue);
}

/* ---------- Toast ---------- */
#toast-box {
  position: fixed;
  top: var(--spacer-16);
  right: var(--spacer-16);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--spacer-8);
  pointer-events: none;
}

.toast {
  background: var(--bg-base-default);
  border: 1px solid var(--border-neutral-l1);
  border-radius: var(--radius-md);
  color: var(--text-default);
  padding: 10px var(--spacer-16);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.error {
  background: var(--google-red-container);
  border-color: #f3b6b0;
  color: #c5221f;
}

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

/* ---------- 空状态 / 提示 ---------- */
.tg-empty {
  text-align: center;
  color: var(--text-tertiary);
  padding: var(--spacer-24);
  font-size: 13px;
}

.tg-note {
  display: flex;
  align-items: flex-start;
  gap: var(--spacer-8);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--bg-surface-tinted);
  border-radius: var(--radius-sm);
  padding: var(--spacer-8) var(--spacer-12);
  line-height: 18px;
}

.tg-note svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---------- 认证页（登录/注册） ---------- */
.tg-auth-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.tg-auth-topbar {
  height: 64px;
  background: var(--bg-base-default);
  border-bottom: 1px solid var(--border-neutral-l1);
  padding: 0 var(--spacer-32);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.tg-auth-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacer-32);
  overflow-y: auto;
}

.tg-auth-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  padding: var(--spacer-32);
}

.tg-auth-card .tg-card-header {
  margin-bottom: var(--spacer-24);
}

.tg-auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacer-12);
  margin-top: var(--spacer-16);
}

/* ---------- 搜索胶囊 ---------- */
.tg-search-container {
  max-width: 600px;
  flex: 1;
  position: relative;
}

.tg-search-pill {
  display: flex;
  align-items: center;
  gap: var(--spacer-12);
  background: var(--bg-surface-tinted);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 8px var(--spacer-20);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tg-search-pill:focus-within {
  background: var(--bg-base-default);
  border-color: var(--border-neutral-l2);
  box-shadow: var(--shadow-sm);
}

.tg-search-pill input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14px;
  color: var(--text-default);
  font-family: inherit;
}

.tg-search-pill input::placeholder {
  color: var(--text-tertiary);
}

/* ---------- 区段标题 ---------- */
.tg-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacer-16);
}

.tg-section-title-wrap h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-default);
  letter-spacing: -0.01em;
}

.tg-section-title-wrap p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: var(--spacer-2);
}

/* ---------- 标签芯片 ---------- */
.tg-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--spacer-6);
  padding: 6px var(--spacer-12);
  border-radius: var(--radius-sm);
  background: var(--bg-base-default);
  border: 1px solid var(--border-neutral-l1);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ---------- 品牌点 ---------- */
.tg-brand-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--google-blue), var(--google-green));
  flex-shrink: 0;
}

/* ---------- 趋势标 ---------- */
.tg-metric-trend {
  display: inline-flex;
  align-items: center;
  gap: var(--spacer-4);
  font-size: 12px;
  font-weight: 600;
}

.tg-trend-up {
  color: var(--google-green);
}

.tg-trend-down {
  color: var(--google-red);
}

/* ---------- 标签栏 ---------- */
.tg-tabs-bar {
  display: flex;
  align-items: center;
  gap: var(--spacer-8);
  border-bottom: 1px solid var(--border-neutral-l1);
  padding-bottom: var(--spacer-8);
}

.tg-tab-item {
  padding: 8px var(--spacer-16);
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.tg-tab-item:hover {
  background: var(--bg-surface-tinted);
  color: var(--text-default);
}

.tg-tab-item.active {
  background: var(--text-default);
  color: #FFFFFF;
  font-weight: 600;
}

/* ---------- 图标容器 ---------- */
.tg-icon-container {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- 颜色点 ---------- */
.tg-color-dot {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: inline-block;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px var(--border-neutral-l1);
}

/* ---------- 工具栏（筛选等） ---------- */
.tg-toolbar {
  display: flex;
  align-items: center;
  gap: var(--spacer-8);
  flex-wrap: wrap;
}

/* ---------- 响应式与移动端抽屉 ---------- */
@media (max-width: 1024px) {
  .tg-grid-3, .tg-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .tg-grid-1-2, .tg-grid-2-1 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .tg-hamburger-btn {
    display: inline-flex;
  }

  .tg-nav-close {
    display: inline-flex;
  }

  .tg-nav-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    z-index: 100;
  }

  .tg-nav-rail.open {
    transform: translateX(0);
  }

  .tg-top-bar {
    padding: 0 var(--spacer-16);
    height: 56px;
  }

  .tg-top-title {
    font-size: 16px;
  }

  .tg-scroll-canvas {
    padding: var(--spacer-16);
  }

  .tg-page-container {
    gap: var(--spacer-20);
  }

  .tg-grid-2, .tg-grid-3, .tg-grid-4 {
    grid-template-columns: 1fr;
    gap: var(--spacer-16);
  }

  .tg-card {
    padding: var(--spacer-16);
    border-radius: var(--radius-lg);
  }

  .tg-card-header {
    margin-bottom: var(--spacer-12);
  }

  .tg-auth-wrap {
    padding: var(--spacer-16);
  }

  .tg-auth-card {
    padding: var(--spacer-20);
  }

  .tg-hero-banner {
    padding: var(--spacer-20);
    border-radius: var(--radius-lg);
  }

  .tg-hero-title {
    font-size: 20px;
    line-height: 28px;
  }

  .tg-table-wrap {
    margin: 0 calc(-1 * var(--spacer-16));
    width: calc(100% + 2 * var(--spacer-16));
    padding: 0 var(--spacer-16);
    -webkit-overflow-scrolling: touch;
  }

  .fusion-table th, .fusion-table td {
    padding: 8px 10px;
    font-size: 12px;
  }
}

/* ---------- 小屏手机深度适配 (<=480px) ---------- */
@media (max-width: 480px) {
  /* 顶栏紧凑：标题省略 + 用户芯片瘦化，避免右侧溢出 */
  .tg-top-bar {
    height: 52px;
    padding: 0 var(--spacer-12);
    gap: var(--spacer-8);
  }
  .tg-top-title { font-size: 15px; }
  .tg-top-actions { gap: var(--spacer-6); }
  .tg-user-chip { padding: 4px var(--spacer-8); font-size: 12px; }
  /* 极窄屏隐藏用户名文本，仅保留头像点 + 套餐徽标 */
  @media (max-width: 380px) {
    .tg-user-chip .dot { display: none; }
    .tg-top-title { max-width: 34vw; }
  }

  /* 指标卡在极窄屏保持两列，充分利用宽度 */
  .tg-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .tg-metric-card { padding: var(--spacer-14, 14px); }
  .tg-metric-title { font-size: 12px; }
  .tg-metric-val { font-size: 22px; }

  /* 弹窗全宽贴边，移动端避免溢出与误触 */
  .tg-modal {
    width: calc(100vw - 24px);
    max-height: 84vh;
    border-radius: var(--radius-lg);
    max-width: 100%;
  }

  /* 表单元素全宽 + 增大点击区域 */
  .tg-form-group { display: block; }
  .tg-input, .tg-btn, .fusion-table input, .fusion-table select {
    width: 100%;
    box-sizing: border-box;
    min-height: 40px;
  }
  .tg-toolbar { flex-direction: column; align-items: stretch; }
  .tg-toolbar .tg-btn { min-height: 42px; }

  /* 抽屉导航更贴合屏幕 */
  .tg-nav-rail { width: 82vw; max-width: 300px; }

  /* 认证/欢迎页：去掉装饰 hero，卡片占满并贴安全区 */
  .tg-hero-banner { display: none; }
  .tg-auth-wrap,
  .tg-auth-card { width: 100%; }

  /* 代码示例与代码块横向可滚动 */
  .tg-code-box { font-size: 11px; overflow-x: auto; }

  /* 按钮/通知条触控间距 */
  .tg-announcement { margin-bottom: var(--spacer-12); }
  .toast { left: 12px; right: 12px; }
}
