@import url("./design-system.css");

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font: 100%/1.5 var(--sans);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { margin: 0; background: var(--canvas); }
button { font: inherit; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
svg { display: block; }

.module-preview { padding: 24px; }

.team-module {
  width: min(1480px, 100%);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(45, 36, 40, 0.08);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-module);
}

html.is-embedded,
html.is-embedded body { background: var(--surface); }
html.is-embedded .module-preview { padding: 0; }
html.is-embedded .team-module {
  width: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.module-header {
  display: grid;
  min-height: 82px;
  grid-template-columns: minmax(220px, 1fr) minmax(390px, 1.25fr) minmax(390px, 1fr);
  align-items: center;
  gap: 28px;
  padding: 16px 20px 16px 24px;
}

.module-title { display: flex; min-width: 0; align-items: center; gap: 12px; }
.title-mark { width: 5px; height: 24px; border-radius: 999px; background: var(--accent); }
.module-title h1 { margin: 0; font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 680; line-height: 1.08; letter-spacing: -0.035em; }

.team-counts { display: flex; align-items: center; justify-content: center; gap: 18px; }
.team-counts > span { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.team-counts b { font-size: 1.25rem; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.team-counts small { color: var(--secondary); font-size: 0.75rem; font-weight: 590; }
.team-counts i { width: 1px; height: 23px; background: var(--line); }

.relation-switch { display: inline-flex; justify-self: end; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface-muted); box-shadow: inset 0 0 0 1px rgba(35, 25, 29, 0.025); }
.relation-button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--secondary); font-size: 0.75rem; font-weight: 590; cursor: pointer; }
.relation-button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(35, 25, 29, 0.10), 0 4px 12px rgba(35, 25, 29, 0.05); }

.network-section { border-top: 1px solid var(--line-soft); background: var(--surface-soft); }
.network-head { display: flex; min-height: 52px; align-items: center; padding: 10px 24px; }
.network-head h2 { margin: 0; font-size: 0.92rem; font-weight: 680; letter-spacing: -0.015em; }

.org-scroll { overflow-x: auto; overscroll-behavior-inline: contain; border-top: 1px solid var(--line-soft); scrollbar-width: none; -ms-overflow-style: none; }
.org-scroll::-webkit-scrollbar { display: none; }
.org-canvas { position: relative; min-width: 1210px; background: var(--surface); }
.connections { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.connection-path { fill: none; vector-effect: non-scaling-stroke; transition: opacity 160ms ease, stroke-width 160ms ease; }
.connection-path[data-kind="management"] { opacity: 0.34; stroke: var(--accent); stroke-width: 1.25; }
.connection-path[data-kind="collaboration"] { opacity: 0.24; stroke: var(--secondary); stroke-width: 1; }
.connection-path[data-kind="support"] { opacity: 0.42; stroke: var(--gold); stroke-width: 1; stroke-dasharray: 4 5; }
.connection-path.is-filtered { opacity: 0.025; }
.connection-path.is-muted { opacity: 0.035; }
.connection-path.is-active { opacity: 1; stroke-width: 2; }

.org-row { position: relative; z-index: 2; display: grid; grid-template-columns: 102px minmax(0, 1fr); padding: 17px 24px 18px 18px; }
.org-row + .org-row { border-top: 1px solid var(--line-soft); }
.decision-layer { min-height: 116px; background: rgba(107, 33, 57, 0.018); }
.command-layer { min-height: 126px; background: rgba(181, 138, 69, 0.025); }
.execution-layer { min-height: 150px; }
.ai-layer { min-height: 164px; background: rgba(181, 138, 69, 0.035); }
.row-label { padding-top: 7px; }
.row-label strong { display: block; color: var(--secondary); font-size: 0.75rem; font-weight: 650; letter-spacing: 0.02em; }
.row-nodes { position: relative; z-index: 3; align-items: start; }
.single-node { display: flex; justify-content: center; }
.single-node .node-card { width: 250px; }
.execution-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.ai-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }

.node-card { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow-card); transition: opacity 160ms ease, border-color 160ms ease, box-shadow 180ms ease, transform 120ms var(--ease-out), background-color 160ms ease; }
.node-card.is-related { border-color: rgba(107, 33, 57, 0.32); box-shadow: 0 8px 24px rgba(35, 25, 29, 0.07); }
.node-card.is-active { z-index: 6; border-color: transparent; background: linear-gradient(145deg, #6f2740, #481626); color: #fff; box-shadow: var(--shadow-focus); }
.node-card.is-muted { opacity: 0.34; }
.node-trigger { display: block; width: 100%; min-height: 100px; padding: 12px 14px 11px; border: 0; border-radius: inherit; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.node-topline { display: flex; align-items: center; justify-content: flex-end; }
.status-tag { font-size: 0.7rem; font-weight: 650; }
.status-tag { color: var(--tertiary); }
.identity { display: flex; min-width: 0; align-items: center; gap: 10px; margin-top: 11px; }
.avatar-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.avatar { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(107, 33, 57, 0.16); border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.92rem; font-weight: 700; }
.identity-copy { min-width: 0; }
.node-name { display: block; overflow: hidden; font-size: 0.9rem; font-weight: 680; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.015em; }
.node-role { display: block; overflow: hidden; margin-top: 3px; color: var(--secondary); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.node-action { display: flex; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--tertiary); }
.node-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 160ms var(--ease-out); }
.node-card.is-active .status-tag, .node-card.is-active .node-role, .node-card.is-active .node-action { color: rgba(255, 255, 255, 0.62); }
.node-card.is-active .avatar { border-color: rgba(255, 255, 255, 0.28); background: #fff; color: var(--accent); }
.node-card.is-active .node-action svg { transform: translateX(2px); }
.node-card[data-status="招聘中"] .avatar { border-style: dashed; background: var(--surface-soft); color: var(--accent); }

.ai-grid .node-card { border-radius: 15px; box-shadow: 0 1px 2px rgba(35, 25, 29, 0.025); }
.ai-grid .node-trigger { min-height: 112px; padding: 11px 10px 10px; text-align: center; }
.ai-grid .node-topline { display: none; }
.ai-grid .status-tag { display: none; }
.ai-grid .identity { display: block; margin-top: 4px; }
.ai-grid .avatar-wrap { display: inline-flex; }
.ai-grid .avatar { width: 38px; height: 38px; border-color: rgba(181, 138, 69, 0.38); border-radius: 12px; background: #eee2c9; color: var(--accent-deep); font-size: 0.8rem; }
.ai-grid .identity-copy { display: block; margin-top: 7px; }
.ai-grid .node-name { font-size: 0.8rem; }
.ai-grid .node-role { font-size: 0.68rem; }
.ai-grid .node-action { display: none; }
.ai-grid .node-card.is-active .avatar { border-color: rgba(255, 255, 255, 0.24); background: #f3e7cf; color: var(--accent-deep); }

.role-inspector { display: grid; min-height: 174px; grid-template-columns: 270px 1fr; border-top: 1px solid var(--line-soft); background: var(--surface); }
.inspector-head { display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 23px 25px; border-right: 1px solid var(--line-soft); }
.inspector-identity { display: flex; align-items: center; gap: 13px; }
.inspector-avatar { display: grid; width: 48px; height: 48px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1rem; font-weight: 720; }
.role-inspector[data-type="ai"] .inspector-avatar { border-radius: 14px; background: #eee2c9; color: var(--accent-deep); }
.inspector-kicker { color: var(--accent); font-size: 0.64rem; font-weight: 680; }
.inspector-head h2 { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.025em; }
.inspector-head p { margin: 4px 0 0; color: var(--secondary); font-size: 0.7rem; }
.inspector-body { display: grid; grid-template-columns: 1fr 1fr 1.25fr; transition: opacity 120ms ease, transform 160ms var(--ease-out); }
.role-inspector.is-updating .inspector-body { opacity: 0.64; transform: translateY(2px); }
.inspector-body article { min-width: 0; padding: 24px 25px; }
.inspector-body article + article { border-left: 1px solid var(--line-soft); }
.inspector-body article > span { color: var(--tertiary); font-size: 0.64rem; font-weight: 650; }
.inspector-body p { margin: 11px 0 0; color: var(--secondary); font-size: 0.78rem; line-height: 1.72; }
.relation-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.relation-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 8px; border-radius: 8px; background: var(--surface-soft); color: var(--secondary); font-size: 0.64rem; }
.relation-chip i { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); }
.relation-chip[data-kind="support"] i { background: var(--gold); }
.relation-chip[data-kind="collaboration"] i { background: var(--secondary); }

.recruitment-bar { display: grid; grid-template-columns: minmax(260px, 0.7fr) minmax(360px, 1.3fr); align-items: center; gap: 24px; padding: 16px 24px; border-top: 1px solid var(--line-soft); background: var(--surface-soft); }
.recruitment-bar > div { display: flex; align-items: baseline; gap: 12px; }
.recruitment-bar > div span { color: var(--accent); font-size: 0.78rem; font-weight: 680; }
.recruitment-bar > div strong { font-size: 0.88rem; }
.recruitment-bar details { justify-self: end; max-width: 620px; }
.recruitment-bar summary { color: var(--secondary); font-size: 0.8rem; font-weight: 640; cursor: pointer; }
.recruitment-bar details[open] summary { color: var(--accent); }
.recruitment-bar p { margin: 10px 0 0; color: var(--secondary); font-size: 0.78rem; line-height: 1.65; }

.global-tooltip { position: fixed; z-index: 100; width: 260px; padding: 14px 15px; pointer-events: none; opacity: 0; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 15px; background: rgba(66, 19, 34, 0.96); color: #fff; box-shadow: 0 18px 42px rgba(35, 11, 15, 0.22); transform: translateY(5px) scale(0.97); transform-origin: 28px 100%; transition: opacity 140ms var(--ease-out), transform 160ms var(--ease-out); }
.global-tooltip.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.global-tooltip strong { display: block; font-size: 0.78rem; font-weight: 680; }
.global-tooltip ul { margin: 9px 0 0; padding: 0; list-style: none; }
.global-tooltip li { position: relative; padding-left: 11px; color: rgba(255, 255, 255, 0.72); font-size: 0.68rem; }
.global-tooltip li + li { margin-top: 4px; }
.global-tooltip li::before { position: absolute; top: 0.58em; left: 0; width: 4px; height: 4px; border-radius: 50%; background: #d5b987; content: ""; }


@media (hover: hover) and (pointer: fine) {
  .relation-button, .node-card { transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, transform 120ms var(--ease-out), box-shadow 160ms ease, opacity 160ms ease; }
  .relation-button:not(.is-active):hover { color: var(--ink); }
  .node-card:hover { border-color: rgba(107, 33, 57, 0.26); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(35, 25, 29, 0.08); }
  .node-card.is-active:hover { transform: translateY(-2px); }
}

.relation-button:active, .node-trigger:active { transform: scale(0.98); transition-duration: 100ms; }
.relation-button:focus-visible, .node-trigger:focus-visible { outline: 2px solid rgba(107, 33, 57, 0.55); outline-offset: 2px; }

@media (max-width: 1080px) {
  .module-header { grid-template-columns: minmax(220px, 1fr) minmax(360px, 1fr); }
  .relation-switch { grid-column: 1 / -1; justify-self: stretch; }
  .relation-button { flex: 1; }
  .role-inspector { grid-template-columns: 240px 1fr; }
  .inspector-body { grid-template-columns: 1fr 1fr; }
  .relation-detail { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); border-left: 0 !important; }
}

@media (max-width: 760px) {
  .module-preview { padding: 9px; }
  .team-module { border-radius: 20px; }
  .module-header { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .team-counts { justify-content: flex-start; gap: 12px; }
  .team-counts small { font-size: 0.72rem; }
  .relation-switch { grid-column: 1; overflow-x: auto; justify-self: stretch; scrollbar-width: none; }
  .relation-switch::-webkit-scrollbar { display: none; }
  .relation-button { min-width: max-content; flex: 1 0 auto; padding: 0 10px; font-size: 0.72rem; }
  .network-head { padding: 13px 16px; }
  .org-scroll { overflow-x: hidden; }
  .org-canvas { min-width: 0; width: 100%; }
  .connections { display: none; }
  .org-row { display: grid; grid-template-columns: 1fr; gap: 10px; min-height: 0; padding: 16px; }
  .row-label { padding: 0; }
  .row-label strong { font-size: 0.78rem; }
  .single-node { justify-content: stretch; }
  .single-node .node-card { width: 100%; }
  .execution-grid,
  .ai-grid {
    display: flex;
    gap: 10px;
    margin-inline: -16px;
    padding: 0 16px 4px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    touch-action: pan-y;
  }
  .execution-grid::-webkit-scrollbar,
  .ai-grid::-webkit-scrollbar { display: none; }
  .execution-grid .node-card,
  .ai-grid .node-card { width: min(82vw, 320px); flex: 0 0 min(82vw, 320px); scroll-snap-align: start; }
  .ai-grid .node-trigger { min-height: 100px; text-align: left; }
  .ai-grid .identity { display: flex; align-items: center; gap: 11px; }
  .ai-grid .identity-copy { margin-top: 0; }
  .ai-grid .node-action { display: flex; }
  .role-inspector { grid-template-columns: 1fr; }
  .inspector-head { flex-direction: row; align-items: center; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .inspector-body { grid-template-columns: 1fr; }
  .inspector-body article { padding: 18px; }
  .inspector-body article + article { border-top: 1px solid var(--line-soft); border-left: 0; }
  .relation-detail { grid-column: auto; }
  .recruitment-bar { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .recruitment-bar > div { display: grid; gap: 4px; }
  .recruitment-bar details { justify-self: stretch; }
}

@media (prefers-reduced-transparency: reduce) {
  .global-tooltip { background: var(--accent-deep); }
}

@media (prefers-contrast: more) {
  .team-module, .node-card { border-color: rgba(0, 0, 0, 0.42); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .node-card, .relation-button, .node-action svg, .inspector-body, .global-tooltip { transition-property: color, background-color, border-color, opacity !important; transition-duration: 140ms !important; transform: none !important; }
}
