/* ══════════════════════════════════════════════════════════════════════
   Navigation — primary rail, context sidebar, topbar controls, page-local
   tabs. 值与 V3.0 原型 assets/navigation-v3.css / app.css 逐项对齐；
   rail/context 为双主题固定深色。几何尺寸见 shell.css / responsive.css。
   ══════════════════════════════════════════════════════════════════════ */

/* ── Primary rail ── */
.rail-brand {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 14px;
  text-decoration: none;
}
.rail-brand::before {
  content: "M";
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #FF4D3A, #E8253F);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(230, 85, 126, 0.22);
}

.rail-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  align-items: center;
}

.rail-item {
  position: relative;
  width: 56px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #9fb1aa;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  transition: 0.16s ease;
}
.rail-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  transform: translateY(-1px);
}
.rail-item.active {
  background: rgba(232, 37, 63, 0.15);
  color: #fff;
  box-shadow: inset 2px 0 #FF4D3A;
}
.rail-item:focus-visible,
.rail-brand:focus-visible {
  outline: 2px solid #FF4D3A;
  outline-offset: -2px;
}
.rail-glyph {
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}
.rail-label {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}
.rail-external-arrow {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 9px;
  color: #ef9eb5;
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rail-icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #9fb1aa;
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  transition: 0.16s ease;
}
.rail-icon-button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.rail-icon-button:focus-visible {
  outline: 2px solid #FF4D3A;
  outline-offset: -2px;
}

/* ── Context sidebar ── */
.context-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px;
}
.context-sidebar-eyebrow {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7f978d;
}
.context-sidebar-title {
  margin: 3px 0 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.context-collapse {
  width: 28px;
  height: 28px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #b8c8c1;
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
}
.context-collapse:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.context-collapse:focus-visible {
  outline: 2px solid #FF4D3A;
  outline-offset: -2px;
}

.context-description {
  margin: 0 4px 12px; /* 12px + 菜单 gap 3px = 原型 15px */
  color: #849b91;
  font-size: 11px;
  line-height: 1.55;
}

.v4-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.context-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #b9c8c2;
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  transition: 0.14s ease;
}
.context-item:hover {
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
}
.context-item.active {
  background: rgba(232, 37, 63, 0.13);
  color: #fff;
  box-shadow: inset 2px 0 #FF4D3A;
}
.context-item:focus-visible {
  outline: 2px solid #FF4D3A;
  outline-offset: -2px;
}
.context-item-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #60776e;
}
.context-item.active .context-item-dot {
  background: #FF4D3A;
  box-shadow: 0 0 0 4px rgba(232, 37, 63, 0.12);
}
.context-item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.context-count {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  font-size: 10px;
  color: #8fa59c;
}
.context-footer {
  margin-top: 15px; /* 15px + gap 3px = 原型 18px */
  padding: 12px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #99ada4;
  font-size: 10px;
}
.context-footer small {
  color: #657b72;
  font-size: 9px;
}

/* 折叠后的展开浮钮（原型折叠后无展开途径，此为可逆性补丁） */
.context-expand-float {
  position: fixed;
  top: 12px;
  left: var(--rail-w);
  z-index: 131;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 0 8px 8px 0;
  background: #221C15;
  color: #b8c8c1;
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  line-height: 1;
}
.context-expand-float:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* 服务商城域二级栏（原型 market sidebar：入口 CTA + 边界说明） */
.context-open-market {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 11px; /* 11px + gap 3px = 原型 14px */
  padding: 12px 13px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FF4D3A, #E8253F);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(230, 85, 126, 0.18);
}
.context-open-market:hover {
  filter: brightness(1.04);
}
.context-note {
  padding: 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.context-note strong {
  font-size: 12px;
  color: #fff;
}
.context-note span {
  font-size: 10px;
  line-height: 1.6;
  color: #8ea39a;
}

/* ── Topbar — V3.0 原型 global-search / workspace-switch / compute-pill /
   top-icon / theme-toggle / user-menu（scoped 覆盖 v4-shell.css） ── */
.app-shell-v4 .v4-global-search {
  position: relative;
  flex: none; /* 原型 topbar-left 无 min-width:0，搜索不随 flex 收缩 */
  width: min(420px, 34vw);
  min-width: 180px;
}
.app-shell-v4 .v4-global-search input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.app-shell-v4 .v4-global-search input::placeholder {
  color: var(--muted);
}
.app-shell-v4 .v4-global-search input:focus {
  border-color: var(--primary);
}
.v4-search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.app-shell-v4 .v4-breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-shell-v4 .v4-breadcrumb-item {
  font-size: 12px;
  color: var(--muted);
}
.app-shell-v4 .v4-breadcrumb-item + .v4-breadcrumb-item::before {
  content: "›";
  color: var(--muted);
}
.app-shell-v4 .v4-breadcrumb-item button {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.app-shell-v4 .v4-breadcrumb-item [aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.v4-workspace-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 5px 8px;
  min-width: 178px;
  max-width: 230px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.v4-workspace-switch:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.v4-workspace-switch:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.workspace-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--tech-soft);
  color: var(--tech);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.workspace-meta {
  min-width: 0;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
}
.workspace-meta strong,
.workspace-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workspace-meta strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.workspace-meta span {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}
.workspace-chevron {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}

.compute-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: var(--tech-soft);
  color: var(--tech);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.compute-pill:hover {
  filter: brightness(0.97);
}
.compute-pill:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.top-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.top-icon:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.top-icon:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.top-icon .v4-badge-dot {
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid #fff;
}
html[data-theme="dark"] .top-icon .v4-badge-dot {
  border-color: var(--surface);
}

.theme-toggle {
  position: relative;
}
.theme-toggle .theme-sun,
.theme-toggle .theme-moon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.theme-toggle .theme-moon {
  display: none;
}
html[data-theme="dark"] .theme-toggle .theme-sun {
  display: none;
}
html[data-theme="dark"] .theme-toggle .theme-moon {
  display: grid;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 4px;
  cursor: pointer;
}
.user-avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, #283b35, #4c6e63);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.user-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

/* 移动端菜单按钮（navigation-state.js 注入到 topbar-left 首位） */
.v4-mobile-menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
}
.v4-mobile-menu-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Page-local tabs (in-page second-level route aggregation) ── */
.page-local-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.page-local-tabs a {
  height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}
.page-local-tabs a:hover {
  color: var(--text);
  background: var(--surface);
}
.page-local-tabs a.active {
  background: var(--surface);
  color: var(--brand-strong);
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(18, 32, 27, 0.08);
}

/* ── Drawer scrim ── 115: 在抽屉（120/130）之下、内容（99）之上，不挡抽屉点击 */
.shell-scrim {
  position: fixed;
  inset: 0;
  z-index: 115;
  border: 0;
  background: color-mix(in srgb, var(--text) 42%, transparent);
}
