/**
 * 平台壳层 · 顶栏 / 侧栏 / 总览页视觉优化
 */

:root {
  --topbar-h: 48px;
  --platform-chrome-z: 200;
  --chrome-icon-btn: 32px;
  --chrome-icon-glyph: 18px;
}

/* 顶栏 / 侧栏 · 统一图标按钮与 glyph 视觉尺寸 */
.chrome-icon-btn {
  width: var(--chrome-icon-btn);
  height: var(--chrome-icon-btn);
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.chrome-icon-btn:hover {
  background: var(--surface-hover, #f5f5f5);
  color: var(--text);
}
.chrome-icon-glyph {
  display: block;
  width: var(--chrome-icon-glyph);
  height: var(--chrome-icon-glyph);
  flex-shrink: 0;
}

/* ── 顶栏 · Cursor Agents ── */
.topbar {
  height: var(--topbar-h);
  padding: 0 12px;
  gap: 0;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  overflow: visible;
  z-index: var(--platform-chrome-z, 200);
}

.topbar__group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}
.topbar__group--end {
  gap: 10px;
}
.topbar__utilities {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topbar__status-cluster {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar__status-cluster--start {
  margin-left: 6px;
}
.topbar__status-cluster--start::before {
  display: none;
}
.topbar__nav-cluster .topbar__status-cluster {
  position: relative;
}
.topbar__shell-cluster {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar__divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 4px;
}
.topbar__group--start {
  gap: 10px;
}

.topbar__nav-cluster {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex-shrink: 1;
  overflow: visible;
}

.topbar__spacer { flex: 1; min-width: 12px; }

/* 首页 + 项目切换（无边框文字下拉） */
.topbar-back {
  width: var(--chrome-icon-btn);
  height: var(--chrome-icon-btn);
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.topbar-back:hover {
  background: var(--surface-hover, #f5f5f5);
  color: var(--text);
}

/* 顶栏 · 侧栏收起/展开（飞书式常驻） */
.topbar-spine-toggle {
  flex-shrink: 0;
  display: inline-flex;
}
body.wb-workbench-focus .topbar-spine-toggle {
  display: none !important;
  pointer-events: none;
}

.topbar__project-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: min(320px, 42vw);
  flex: 0 1 auto;
  width: max-content;
}
.topbar__project-select {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: content-box;
  width: auto;
  min-width: 3em;
  max-width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  cursor: pointer;
  text-overflow: ellipsis;
  transition: color 0.15s;
  /* 现代浏览器：按选中文案收缩；其余走 JS fitProjectSelectWidth */
  field-sizing: content;
}
.topbar__project-select:hover { color: var(--primary); }
.topbar__project-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}
.topbar__project-chevron {
  position: static;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin: 0;
  pointer-events: none;
  color: var(--muted);
  opacity: 0.75;
  transform: none;
}
.topbar__project-switch:hover .topbar__project-chevron {
  color: var(--text);
  opacity: 0.55;
}

.topbar__link {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.topbar__link:hover {
  color: var(--text);
  background: var(--surface-hover, #f5f5f5);
}

.topbar__brand {
  font-weight: 650;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}

.topbar__nav { gap: 2px; margin-left: 4px; }
.nav-tab {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
}
.nav-tab.is-active {
  background: var(--surface-active);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.nav-tab:hover:not(.is-active) {
  background: var(--surface-hover, #f5f5f5);
}

.select {
  height: 32px;
  padding: 0 28px 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.select:hover { border-color: var(--accent-border-strong, var(--border)); }
.select:focus {
  outline: none;
  border-color: var(--accent-border-strong, #ccc);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}
.select--workbench { min-width: 140px; }
.select--sm {
  height: 28px;
  font-size: 12px;
  padding-left: 8px;
}

.mode-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 2px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  height: 32px;
}
.mode-select-wrap .mode-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.mode-select-wrap .select {
  border: none;
  background: transparent;
  height: 28px;
  padding-left: 4px;
  box-shadow: none;
}
.mode-select-wrap .select:focus { box-shadow: none; }

.shell-mode-toggle {
  background: var(--cursor-bg-input, var(--surface-hover));
  border: 1px solid var(--border);
  padding: 2px;
  border-radius: var(--cursor-radius-md, 8px);
}
.shell-mode-btn {
  font-size: var(--cursor-text-xs, 11px);
  font-weight: var(--cursor-weight-medium, 500);
  padding: 5px 10px;
  letter-spacing: 0.01em;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--cursor-radius-sm, 6px);
  line-height: 1.2;
  white-space: nowrap;
}
.shell-mode-btn:hover { color: var(--text); }
.shell-mode-btn.is-active {
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: none;
}

.sync-badge {
  background: var(--surface-hover);
  border-color: var(--border);
  font-size: var(--cursor-text-xs, 11px);
}
.sync-badge.is-live {
  color: var(--success);
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
}

.auth-bar {
  border-radius: var(--cursor-radius-full, 999px);
  background: var(--surface-elevated);
  border-color: var(--border);
}

.select {
  border-radius: var(--cursor-radius-md, 8px);
  font-size: var(--cursor-text-sm, 13px);
  background: var(--input-bg);
  border-color: var(--border);
}

.mode-select-wrap {
  border-radius: var(--cursor-radius-md, 8px);
  background: var(--input-bg);
  border-color: var(--border);
  height: 30px;
}

.theme-toggle {
  border-radius: var(--cursor-radius-md, 8px);
  border-color: var(--border);
  background: transparent;
}

.workbench { height: calc(100vh - var(--topbar-h)); }

/* 主题切换 · Solar 图标（见 solar-icons.css） */
.theme-toggle {
  width: var(--chrome-icon-btn);
  height: var(--chrome-icon-btn);
  border-radius: 8px;
}
.theme-toggle__icon { display: none !important; }

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
  background: var(--surface-hover, #f5f5f5);
  border: 1px solid var(--border);
  margin: 0;
  white-space: nowrap;
}
.sync-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.sync-badge.is-live { color: #2d8a4e; background: rgba(113, 221, 140, 0.12); border-color: rgba(113, 221, 140, 0.35); }
.sync-badge.is-live::before { background: var(--success); }
.sync-badge.is-stale { color: #b8860b; background: rgba(255, 204, 0, 0.1); border-color: rgba(255, 204, 0, 0.35); }
.sync-badge.is-stale::before { background: var(--warning); }

/* 平台服务 + 资源同步 · 合并状态（Cursor 式：点状指示 + 中性底，不用彩色胶囊） */
.platform-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 6px;
  border-radius: var(--cursor-radius-sm, 6px);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  background: transparent;
  border: none;
  margin: 0;
  white-space: nowrap;
  cursor: pointer;
  font: inherit;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: background 0.15s, color 0.15s;
}
.platform-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--status-dot-pending, var(--muted));
  flex-shrink: 0;
}
.platform-status--pending { color: var(--muted); }
.platform-status--pending::before { background: var(--status-dot-pending); }
.platform-status--ok {
  color: var(--muted);
}
.platform-status--ok::before { background: var(--status-dot-ok); }
.platform-status--warn {
  color: var(--muted);
}
.platform-status--warn::before { background: var(--status-dot-warn); }
.platform-status--error {
  color: var(--muted);
}
.platform-status--error::before { background: var(--status-dot-error); }

.platform-status:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.platform-status[aria-expanded="true"] {
  background: var(--surface-active);
  color: var(--text);
  box-shadow: none;
}

.platform-status-panel {
  position: fixed;
  z-index: calc(var(--platform-chrome-z, 200) + 10);
  width: min(320px, calc(100vw - 24px));
  padding: 0;
  border-radius: var(--cursor-radius-lg, 12px);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  box-shadow: var(--cursor-shadow-md, 0 12px 40px rgba(15, 23, 42, 0.14));
}
.platform-status-panel[hidden] { display: none !important; }
.topbar__utilities { position: relative; }
.platform-status-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.platform-status-panel__close {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
}
.platform-status-panel__close:hover { background: var(--surface-hover); }
.platform-status-panel__body { padding: 10px 14px; }
.platform-status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
}
.platform-status-row:last-child { border-bottom: none; }
.platform-status-row__label { color: var(--muted); flex-shrink: 0; }
.platform-status-row__value { text-align: right; color: var(--text); font-weight: 550; }
.platform-status-row__value.is-ok { color: var(--status-text-ok); }
.platform-status-row__value.is-warn { color: var(--status-text-warn); }
.platform-status-row__value.is-error { color: var(--status-text-error); }
.platform-status-panel__hint {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-hover);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.platform-status-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  align-items: center;
}
.platform-status-panel__actions .btn { font-size: 12px; padding: 5px 10px; }
.platform-status-panel__actions .btn.is-loading {
  opacity: 0.72;
  pointer-events: none;
}
.platform-status-panel__feedback {
  flex: 1 1 100%;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.platform-status-panel__feedback.is-loading { color: var(--muted); }
.platform-status-panel__feedback.is-ok { color: var(--status-text-ok); }
.platform-status-panel__feedback.is-error { color: var(--status-text-error); }

.topbar__conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
}
.topbar__conn .status-dot {
  width: 6px;
  height: 6px;
  margin: 0;
}

.auth-bar {
  gap: 8px;
  margin: 0;
  padding: 2px 4px 2px 2px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.auth-bar__avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e6e6e6, #f5f5f5);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.auth-bar__user {
  font-weight: 550;
  font-size: 12px;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-bar__team-select {
  max-width: min(280px, 34vw);
  min-width: 120px;
  width: auto;
  flex-shrink: 0;
  border: 1px solid var(--btn-ghost-border, var(--border));
  background: var(--input-bg);
  color: var(--text);
  height: 26px;
  padding-right: 24px;
}
.auth-bar__team-select:hover {
  border-color: var(--btn-ghost-hover-border, var(--accent-border-strong));
  background: var(--btn-ghost-hover-bg, var(--surface-hover));
}
.auth-bar__team-select:focus {
  outline: none;
  border-color: var(--accent-border-strong);
  box-shadow: 0 0 0 1px var(--accent-border-strong);
}
.auth-bar .btn--sm {
  padding: 4px 10px;
  font-size: 12px;
  height: 26px;
  border-radius: 999px;
}

/* 侧栏基础 */
.platform-sidebar,
.spine {
  background: var(--surface);
}
.platform-sidebar h4,
.spine h4,
.wb-nav-group h4 {
  margin: 14px 0 6px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.spine-item {
  padding: 7px 10px;
  margin-bottom: 1px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s;
}
.spine-item:hover { background: var(--surface-hover, #f5f5f5); }
.spine-item.is-active {
  background: var(--surface-active);
  font-weight: 600;
}

/* ── 项目总览 ── */
.wb-panel--overview {
  padding: 28px 32px 40px;
  max-width: 960px;
  margin: 0 auto;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.wb-overview-hero {
  margin-bottom: 28px;
}
.wb-overview-hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}
.wb-overview-hero p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 52em;
}

.wb-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.wb-stat-card {
  position: relative;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.wb-stat-card:hover {
  border-color: var(--accent-border-strong, #ccc);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}
.wb-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--border);
}
.wb-stat-card__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.wb-stat-card__value {
  display: block;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.wb-stat-card__meta {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.wb-stat-card--empty .wb-stat-card__value {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}

.wb-readme-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.wb-readme-card__head {
  padding: 12px 18px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-muted, #f9f9fa);
  border-bottom: 1px solid var(--border);
}
.wb-readme-card__body {
  padding: 20px 22px 28px;
  font-size: 14px;
  line-height: 1.7;
}
.wb-readme-card__body.md-preview h1 { font-size: 1.35em; margin-top: 0; }
.wb-readme-card__body.md-preview h2 { font-size: 1.15em; margin-top: 1.4em; }
.wb-readme-card__body.md-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0;
}
.wb-readme-card__body.md-preview th,
.wb-readme-card__body.md-preview td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}
.wb-readme-card__body.md-preview th {
  background: var(--surface-muted, #f9f9fa);
  font-weight: 600;
}

[data-theme="dark"] .auth-bar__avatar {
  background: linear-gradient(145deg, #484848, #404040);
}
[data-theme="dark"] .auth-bar {
  background: var(--surface);
  border-color: var(--btn-ghost-border, var(--accent-border-strong));
}
[data-theme="dark"] .auth-bar__team-select {
  background: var(--input-bg);
  border-color: var(--btn-ghost-border, var(--accent-border-strong));
  color: var(--text);
}
[data-theme="dark"] .auth-bar .btn--ghost {
  background: var(--btn-ghost-bg, rgba(255, 255, 255, 0.04));
  border-color: var(--btn-ghost-border, rgba(255, 255, 255, 0.18));
  color: var(--text);
}
[data-theme="dark"] .auth-bar .btn--ghost:hover {
  color: var(--text);
}
[data-theme="dark"] .theme-toggle {
  border-color: var(--btn-ghost-border, var(--accent-border-strong));
  color: var(--muted);
}
[data-theme="dark"] .theme-toggle:hover {
  color: var(--text);
  border-color: var(--btn-ghost-hover-border, rgba(255, 255, 255, 0.26));
  background: var(--btn-ghost-hover-bg, rgba(255, 255, 255, 0.08));
}
[data-theme="dark"] .wb-readme-card__head,
[data-theme="dark"] .wb-readme-card__body.md-preview th {
  background: rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .wb-stat-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

@media (max-width: 1100px) {
  .topbar__project-switch { max-width: min(180px, 24vw); }
  .topbar__project-select { font-size: 13px; }
  .auth-bar__user { max-width: 64px; }
}
@media (max-width: 900px) {
  .topbar__divider { display: none; }
  .mode-select-wrap .mode-label { display: none; }
}
