:root {
  --bg: #f2f5fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.08);
  --ink: #111827;
  --muted: #667085;
  --accent: #3478f6;
  --accent-soft: rgba(52, 120, 246, 0.12);
  --shadow: 0 24px 80px rgba(17, 24, 39, 0.08);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "SF Pro Display", "Segoe UI", "PingFang SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(52, 120, 246, 0.11), transparent 24%),
    radial-gradient(circle at right 14%, rgba(14, 165, 233, 0.08), transparent 20%),
    linear-gradient(180deg, #f9fbff 0%, #f3f6fb 52%, #eef3f9 100%);
}

a {
  color: inherit;
}

.shell {
  width: 100%;
  min-height: 100vh;
  padding: 14px;
}

.frame {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 28px);
}

.sidebar,
.workspace {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.brand {
  display: grid;
  gap: 10px;
  padding: 10px 6px 0;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.nav-group {
  display: grid;
  gap: 10px;
}

.nav-title {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-item {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.nav-item:hover {
  transform: translateY(-1px);
  border-color: rgba(52, 120, 246, 0.2);
  box-shadow: 0 12px 32px rgba(52, 120, 246, 0.08);
}

.nav-item.active {
  border-color: rgba(52, 120, 246, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(242, 248, 255, 0.93));
  box-shadow: 0 12px 28px rgba(52, 120, 246, 0.14);
}

.nav-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.nav-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.workspace {
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.workspace-head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.84);
}

.workspace-title strong {
  display: block;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.workspace-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.workspace-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill,
.tool-btn,
.ghost-btn,
.open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.status-pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
}

.tool-btn,
.open-btn {
  border: 0;
  background: linear-gradient(135deg, #4b8cff, #2f6ef2);
  color: white;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.content {
  min-height: 0;
  padding: 14px;
  background: linear-gradient(180deg, rgba(250, 251, 255, 0.94), rgba(245, 248, 252, 0.92));
}

.hub-content {
  display: grid;
  min-height: 0;
}

.hub-view {
  display: none;
  min-height: 0;
}

.hub-view.active {
  display: grid;
}

.hub-frame-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.06);
  padding: 8px;
  display: grid;
  gap: 8px;
  min-height: 100%;
}

.hub-frame-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
}

.hub-frame-meta {
  display: grid;
  gap: 2px;
}

.hub-frame-meta span {
  color: var(--muted);
  font-size: 11px;
}

.hub-frame-meta strong {
  font-size: 12px;
  letter-spacing: -0.02em;
}

.hub-frame-shell {
  position: relative;
  min-height: calc(100vh - 136px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(248, 250, 255, 0.96), rgba(241, 245, 249, 0.96));
}

.hub-frame-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  background: linear-gradient(180deg, rgba(248, 250, 255, 0.96), rgba(241, 245, 249, 0.96));
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.hub-frame-loading.active {
  opacity: 1;
}

.hub-frame {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 136px);
  border: 0;
  background: white;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.hub-frame.ready {
  opacity: 1;
  transform: translateY(0);
}

.home-grid,
.detail-grid,
.summary-grid,
.module-grid {
  display: grid;
  gap: 16px;
}

.home-grid,
.module-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.hero-card,
.module-card,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.hero-card {
  grid-column: 1 / -1;
  padding: 16px;
  display: grid;
  gap: 14px;
  background:
    radial-gradient(circle at top right, rgba(52, 120, 246, 0.1), transparent 20%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 248, 255, 0.94));
}

.hero-card h2,
.module-card h3,
.detail-card h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.hero-card p,
.module-card p,
.detail-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(251, 252, 255, 0.9);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.module-card,
.detail-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.module-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.module-list,
.info-list {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.module-list div::before,
.info-list div::before {
  content: "•";
  color: var(--accent);
  margin-right: 8px;
}

.module-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-grid .metric strong {
  font-size: 22px;
}

.mono {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 12px;
}

.note-box {
  border: 1px dashed rgba(52, 120, 246, 0.28);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(52, 120, 246, 0.04);
  color: var(--muted);
  line-height: 1.7;
  font-size: 13px;
}

@media (max-width: 1240px) {
  .detail-grid,
  .summary-grid,
  .home-grid,
  .module-grid,
  .hero-metrics {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 1080px) {
  .frame {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .summary-grid,
  .home-grid,
  .module-grid,
  .hero-metrics {
    grid-template-columns: 1fr;
  }
}

/* Embedded child page mode: keep only content area when rendered inside /home iframe */
body.embed-mode .shell {
  padding: 0;
  min-height: auto;
}

body.embed-mode .frame {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-height: auto;
}

body.embed-mode .sidebar,
body.embed-mode .workspace-head {
  display: none;
}

body.embed-mode .workspace {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

body.embed-mode .content {
  padding: 8px;
  background: transparent;
}
