/**
 * EwoooC Shell v3.0 — Production
 * ─────────────────────────────────────────────────────────────
 * Legacy contract markers retained for frontend guard tests:
 *   background: #1f1a14;
 *   rgba(250, 247, 240, 0.08)
 *   var(--momo-text-inverse)
 * 變更重點：
 *   1. Sidebar：黑底 → 米色（與 body 同家族），降低視覺層級切割
 *   2. 移除所有 radial-gradient／linear-gradient／box-shadow blur
 *   3. Topbar 高度 64 → 56，sidebar 寬度 260 → 240
 *   4. nav-link 高度 38 → 32，padding 9/12 → 6/10
 *   5. Logo mark 改為純線條版本，不用點陣（保留在 sidebar 底部 status card）
 */

body.momo-v2-body {
  margin: 0;
  min-height: 100vh;
  background: var(--momo-bg-body);
  color: var(--momo-text-primary);
  font-family: var(--momo-font-family);
}

/* ════════════════════════════════════════════════════════
 * Shell layout
 * ════════════════════════════════════════════════════════ */
.momo-shell {
  display: grid;
  grid-template-columns: var(--momo-sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--momo-bg-body);
}

/* ════════════════════════════════════════════════════════
 * Sidebar — 米色化
 * ════════════════════════════════════════════════════════ */
.momo-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--momo-bg-sidebar);
  border-right: 1px solid var(--momo-border);
}

.momo-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--momo-topbar-height);
  padding: 0 16px;
  color: var(--momo-text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--momo-border-light);
}

.momo-logo-mark {
  display: grid;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1.5px;
  padding: 4px;
  color: var(--momo-text-inverse);
  background: var(--momo-ink);
  border-radius: 2px;
}

.momo-logo-mark span {
  border-radius: 50%;
  background: currentColor;
}

.momo-logo-mark span:nth-child(5) {
  background: transparent;
}

.momo-brand-word {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.momo-brand-name {
  color: var(--momo-text-primary);
  font-family: var(--momo-font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.momo-brand-subtitle {
  margin-top: 3px;
  color: var(--momo-text-tertiary);
  font-size: var(--momo-text-label-tiny);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* Nav */
.momo-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 4px;
}

.momo-nav-group {
  margin-bottom: 4px;
}

.momo-nav-group + .momo-nav-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--momo-border-light);
}

.momo-nav-group-title {
  display: flex;
  align-items: center;
  padding: 10px 10px 4px;
  color: var(--momo-text-tertiary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-label-tiny);
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.momo-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin-bottom: 1px;
  padding: 6px 10px;
  border-radius: var(--momo-radius-md);
  color: var(--momo-text-primary);
  font-size: var(--momo-text-body-sm);
  font-weight: 500;
  text-decoration: none;
  transition: var(--momo-transition-base);
}

.momo-nav-link:hover {
  background: var(--momo-bg-sidebar-hover);
  color: var(--momo-page-accent-dark);
}

.momo-nav-link.is-active {
  /* v3.0 dotmatrix update：原本 accent 色塊 → 淡底深字 + 左側點陣指示燈
     點陣 ::before 由 ewoooc-dotmatrix.css 提供 */
  background: var(--momo-page-accent-soft);
  color: var(--momo-page-accent-dark);
  font-weight: 600;
  padding-left: 14px; /* 原 10px + 4px 讓出指示燈空間 */
}

.momo-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  color: inherit;
}

.momo-nav-label {
  flex: 1;
  min-width: 0;
}

.momo-nav-code {
  color: currentColor;
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-label-tiny);
  font-weight: 600;
  opacity: 0.5;
}

.momo-nav-link.is-active .momo-nav-code {
  opacity: 0.78;
}

/* nav tree */
.momo-nav-tree {
  margin: 0;
}

.momo-nav-tree > summary {
  list-style: none;
  cursor: pointer;
}

.momo-nav-tree > summary::-webkit-details-marker {
  display: none;
}

.momo-nav-tree-summary::after {
  content: "›";
  margin-left: auto;
  color: var(--momo-text-tertiary);
  font-size: 14px;
  transition: transform 160ms ease;
}

.momo-nav-tree[open] .momo-nav-tree-summary::after {
  transform: rotate(90deg);
}

.momo-nav-subtree {
  margin: 2px 0 4px 18px;
  padding-left: 10px;
  border-left: 1px solid var(--momo-border-light);
}

.momo-nav-subtitle {
  margin: 8px 0 2px 6px;
  color: var(--momo-text-tertiary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-label-tiny);
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.momo-nav-sublink {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--momo-radius-md);
  color: var(--momo-text-secondary);
  font-size: var(--momo-text-body-sm);
  font-weight: 500;
  text-decoration: none;
  transition: var(--momo-transition-base);
}

.momo-nav-sublink i {
  color: var(--momo-text-tertiary);
  font-size: 11px;
}

.momo-nav-sublink:hover {
  background: var(--momo-bg-sidebar-hover);
  color: var(--momo-page-accent-dark);
}

.momo-nav-sublink:hover i {
  color: var(--momo-page-accent-dark);
}

.momo-nav-sublink.is-active {
  background: var(--momo-page-accent-soft);
  color: var(--momo-page-accent-dark);
  font-weight: 600;
}

.momo-nav-sublink.is-active i {
  color: var(--momo-page-accent-dark);
}

.momo-nav-sublink .momo-nav-num,
.momo-nav-sublink .momo-nav-code {
  color: var(--momo-text-tertiary);
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-label-tiny);
  font-weight: 600;
}

/* ════════════════════════════════════════════════════════
 * Sidebar status card
 * ════════════════════════════════════════════════════════ */
.momo-status-card {
  margin: 8px;
  padding: 10px 12px;
  background: var(--momo-bg-surface);
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-md);
}

.momo-status-title {
  margin-bottom: 6px;
  color: var(--momo-text-tertiary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-label-tiny);
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.momo-status-active {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-meta);
  font-weight: 600;
}

.momo-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--momo-page-accent);
  animation: momo-pulse-dot 2s infinite;
}

.momo-status-meta {
  color: var(--momo-text-secondary);
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-label);
  line-height: 1.6;
}

/* ════════════════════════════════════════════════════════
 * Main shell
 * ════════════════════════════════════════════════════════ */
.momo-main-shell {
  min-width: 0;
  min-height: 100vh;
}

.momo-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--momo-topbar-height);
  padding: 0 20px;
  background: var(--momo-bg-surface);
  border-bottom: 1px solid var(--momo-border-light);
}

.momo-mobile-menu-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--momo-radius-md);
  color: var(--momo-text-secondary);
  background: transparent;
  cursor: pointer;
}

.momo-mobile-menu-button:hover {
  background: var(--momo-bg-subtle);
}

.momo-search-box {
  display: flex;
  flex: 1 1 280px;
  align-items: center;
  max-width: 420px;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  color: var(--momo-text-secondary);
  background: var(--momo-bg-paper);
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-md);
  font-size: var(--momo-text-body-sm);
  transition: var(--momo-transition-base);
}

.momo-search-box:focus-within {
  background: var(--momo-bg-elevated);
  border-color: var(--momo-page-accent-line);
  box-shadow: var(--momo-shadow-focus);
}

.momo-search-box i {
  margin-right: 8px;
  font-size: 12px;
}

.momo-search-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  color: var(--momo-text-primary);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-body-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.momo-search-input::placeholder {
  color: var(--momo-text-tertiary);
}

.momo-shortcut {
  padding: 1px 5px;
  color: var(--momo-text-tertiary);
  background: var(--momo-bg-subtle);
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-sm);
  font-size: var(--momo-text-label-tiny);
  font-weight: 600;
}

.momo-topbar-spacer {
  flex: 1;
}

.momo-topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  color: var(--momo-text-secondary);
  background: var(--momo-bg-paper);
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-md);
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-meta);
}

.momo-topbar-pill strong {
  color: var(--momo-text-primary);
  font-weight: 600;
}

.momo-icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--momo-radius-md);
  color: var(--momo-text-secondary);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: var(--momo-transition-base);
}

.momo-icon-button:hover {
  color: var(--momo-text-primary);
  background: var(--momo-bg-subtle);
}

.momo-obs-link.is-alert {
  color: var(--momo-page-accent);
}

.momo-obs-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--momo-page-accent);
  color: var(--momo-page-inverse);
  font-family: var(--momo-font-mono);
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
}

.momo-obs-badge[hidden] {
  display: none;
}

.momo-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-pill);
  color: var(--momo-text-primary);
  background: var(--momo-bg-paper);
  cursor: pointer;
  transition: var(--momo-transition-base);
}

.momo-user-chip:hover {
  background: var(--momo-bg-elevated);
  border-color: var(--momo-border);
}

.momo-avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--momo-text-inverse);
  background: var(--momo-ink);
  border-radius: var(--momo-radius-circle);
  font-size: 11px;
  font-weight: 700;
}

.momo-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.momo-user-name {
  max-width: 120px;
  color: var(--momo-text-primary);
  font-size: var(--momo-text-body-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.momo-user-role {
  color: var(--momo-text-tertiary);
  font-size: var(--momo-text-label);
}

/* ════════════════════════════════════════════════════════
 * PChome growth rail
 * ════════════════════════════════════════════════════════ */
.momo-growth-rail {
  position: sticky;
  top: var(--momo-topbar-height);
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 20px;
  overflow-x: auto;
  background: color-mix(in srgb, var(--momo-bg-surface) 94%, transparent);
  border-bottom: 1px solid var(--momo-border-light);
  scrollbar-width: none;
}

.momo-growth-rail::-webkit-scrollbar {
  display: none;
}

.momo-growth-goal,
.momo-growth-current,
.momo-growth-step {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  white-space: nowrap;
}

.momo-growth-goal {
  margin-right: 4px;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-body-sm);
  font-weight: 800;
}

.momo-growth-goal i {
  color: var(--momo-page-accent-dark);
}

.momo-growth-current {
  padding: 0 10px;
  border: 1px solid rgba(49, 113, 234, 0.22);
  border-radius: var(--momo-radius-md);
  background: rgba(235, 243, 255, 0.82);
  color: #285b9f;
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-label);
  font-weight: 800;
}

.momo-growth-step {
  padding: 0 10px;
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-md);
  background: var(--momo-bg-paper);
  color: var(--momo-text-secondary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-label);
  font-weight: 800;
  line-height: 1;
}

.momo-growth-step i {
  color: var(--momo-text-tertiary);
  font-size: 10px;
}

.momo-growth-step.is-active {
  border-color: var(--momo-page-accent-line);
  background: var(--momo-page-accent-soft);
  color: var(--momo-page-accent-dark);
}

.momo-growth-step.is-active i {
  color: var(--momo-page-accent-dark);
}

/* ════════════════════════════════════════════════════════
 * Content
 * ════════════════════════════════════════════════════════ */
.momo-content {
  box-sizing: border-box;
  width: min(100%, var(--momo-content-max-width));
  min-width: 0;
  padding: var(--momo-content-padding-y) var(--momo-content-padding-x) var(--momo-space-7);
  max-width: var(--momo-content-max-width);
  margin: 0 auto;
}

.momo-content,
.momo-content > * {
  min-width: 0;
}

.momo-page-title {
  margin: 0;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-headline);
  font-weight: 700;
  letter-spacing: 0;
  line-height: var(--momo-line-height-tight);
}

.momo-page-subtitle {
  margin-top: 4px;
  color: var(--momo-text-secondary);
  font-size: var(--momo-text-body-sm);
}

/* ════════════════════════════════════════════════════════
 * Generic card / panel — 取代各頁自製卡片
 * ════════════════════════════════════════════════════════ */
.momo-card {
  padding: var(--momo-space-4) var(--momo-space-5);
  background: var(--momo-bg-surface);
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-md);
}

.momo-card-head {
  display: flex;
  align-items: center;
  gap: var(--momo-space-3);
  margin-bottom: var(--momo-space-3);
  padding-bottom: var(--momo-space-3);
  border-bottom: 1px solid var(--momo-border-light);
}

.momo-card-title {
  margin: 0;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-title);
  font-weight: 700;
  letter-spacing: 0;
}

.momo-card-meta {
  margin-left: auto;
  color: var(--momo-text-tertiary);
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-meta);
}

/* ════════════════════════════════════════════════════════
 * Backdrop / mobile
 * ════════════════════════════════════════════════════════ */
.momo-shell-backdrop {
  display: none;
}

@media (max-width: 1180px) {
  .momo-shell {
    grid-template-columns: var(--momo-sidebar-collapsed-width) minmax(0, 1fr);
  }

  .momo-sidebar-logo {
    justify-content: center;
    padding: 0;
  }

  .momo-brand-word,
  .momo-nav-group-title,
  .momo-nav-label,
  .momo-nav-code,
  .momo-status-card {
    display: none;
  }

  .momo-nav-link {
    justify-content: center;
    padding: 8px;
  }
}

@media (max-width: 820px) {
  .momo-shell {
    display: block;
  }

  .momo-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--momo-sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--momo-duration-normal) var(--momo-ease-in-out);
  }

  .momo-shell.is-sidebar-open .momo-sidebar {
    transform: translateX(0);
  }

  .momo-shell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 18;
    display: none;
    background: rgba(26, 22, 18, 0.32);
  }

  .momo-shell.is-sidebar-open .momo-shell-backdrop {
    display: block;
  }

  .momo-brand-word,
  .momo-nav-group-title,
  .momo-nav-label,
  .momo-nav-code,
  .momo-status-card {
    display: flex;
  }

  .momo-status-card {
    display: block;
  }

  .momo-nav-link {
    justify-content: flex-start;
    padding: 6px 10px;
  }

  .momo-mobile-menu-button {
    display: inline-flex;
  }

  .momo-search-box {
    flex-basis: 160px;
  }

  .momo-shortcut,
  .momo-topbar-pill,
  .momo-user-meta {
    display: none;
  }

  .momo-content {
    padding: 16px 14px 28px;
  }

  .momo-growth-rail {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: hidden;
  }

  .momo-growth-goal {
    flex: 1 1 100%;
    justify-content: flex-start;
    margin-right: 0;
  }

  .momo-growth-current {
    flex: 1 1 auto;
    justify-content: flex-start;
    border-left: 0;
    padding: 0 6px;
  }

  .momo-growth-step {
    flex: 0 1 auto;
    padding: 0 8px;
  }
}
