:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f6f6f4;
  --bg-bar: rgba(255, 255, 255, 0.84);
  --bg-hover: #f3f3f0;
  --border: rgba(20, 20, 18, 0.08);
  --text: #161616;
  --muted: #6f6f6b;
  --accent: #3d7a1f;
  --shadow: 0 8px 28px rgba(20, 20, 18, 0.08), 0 1px 2px rgba(20, 20, 18, 0.04);
  --bar-h: 60px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 4px 12px;
  padding: 0 20px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 180ms var(--ease), transform 180ms var(--ease);
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  display: block;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(20, 20, 18, 0.08);
  transition: transform 180ms var(--ease);
}
.brand-text { line-height: 1; font-size: 1.02rem; }
.brand .accent { color: var(--accent); }
.brand:hover { background: var(--bg-hover); }
.brand:hover .brand-logo { transform: scale(1.04); }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav-item { position: relative; flex: 0 0 auto; }

.nav-link,
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 550;
  font-size: 0.95rem;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.nav-link:hover,
.nav-btn:hover,
.nav-item.open > .nav-btn,
.nav-link.is-current,
.nav-btn[aria-current="page"] {
  color: var(--text);
  background: var(--bg-hover);
}
.nav-btn .caret {
  font-size: 0.62rem;
  opacity: 0.7;
  transform: translateY(1px);
  transition: transform 180ms var(--ease);
}
.nav-item.open > .nav-btn .caret { transform: translateY(1px) rotate(180deg); }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  max-width: min(92vw, 560px);
  padding: 8px 0 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 180ms;
}
.dropdown-panel {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.nav-item.open > .dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.dropdown.cols-2 .dropdown-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px 16px;
  min-width: 360px;
}

.group-title {
  margin: 4px 8px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #9a9a94;
}

.tool-link {
  display: block;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text);
  transition: background 160ms var(--ease);
}
.tool-link:hover,
.tool-link.active { background: var(--bg-hover); }
.tool-link .t-name { display: block; font-weight: 600; font-size: 0.94rem; }
.tool-link .t-desc {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}
.tool-link .t-desc:empty { display: none; }

.empty-hint {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.ghost {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: color 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
}
.ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--border);
}
.ghost[hidden] { display: none !important; }

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.welcome {
  width: min(820px, calc(100% - 48px));
  margin: 72px auto 48px;
}
.welcome .eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
}
.welcome h1 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 3.6vw, 2.25rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.welcome .lead {
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 32rem;
}

.overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.overview-card {
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 1px 0 rgba(20, 20, 18, 0.02);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}
.overview-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(20, 20, 18, 0.12);
}
.overview-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 650;
}
.overview-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.overview-card .empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.tool-shell {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.tool-shell.active { display: flex; }

.tool-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.85rem;
}
.tool-meta strong { color: var(--text); font-weight: 620; }
.tool-meta .sep { opacity: 0.35; }

.frame-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg-soft);
}
.frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

.fallback {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  text-align: center;
}
.fallback.show { display: grid; }
.fallback h2 { margin: 0 0 8px; font-size: 1.1rem; }
.fallback p { margin: 0 0 16px; color: var(--muted); }
.fallback .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}
.fallback .btn:hover { transform: translateY(-1px); }

.loading {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}
.loading.show { display: grid; }

@media (max-width: 720px) {
  .topbar { padding: 0 10px; }
  .welcome { margin-top: 40px; width: min(820px, calc(100% - 32px)); }
  .overview { grid-template-columns: 1fr; }
  .dropdown.cols-2 {
    min-width: min(92vw, 320px);
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    transform: none !important;
  }
}
