/* screens-desktop-shared.jsx — 共享 AppShell 组件，对齐 officev3 真实侧边栏
   所有桌面端设计稿屏幕共用此 AppShell
*/
/* global React */

/* ─────────────────────────────────────────────
   真实 SVG 图标（路径来自 officev3/public/svgs/）
   ───────────────────────────────────────────── */
function IcAsset({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g transform="translate(0,-2)">
        <path d="M10.5,4.5 L9,4.5 L2,4.5 C1.17,4.5 0.5,5.17 0.5,6 L0.5,8 C0.5,8.83 1.17,9.5 2,9.5 L12,9.5 C12.83,9.5 13.5,8.83 13.5,8 L13.5,8"
          stroke={c} strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" />
        <path d="M0.5,14 L0.5,16 C0.5,16.83 1.17,17.5 2,17.5 L12,17.5 C12.83,17.5 13.5,16.83 13.5,16 L13.5,14 C13.5,13.17 12.83,12.5 12,12.5 L2,12.5 C1.17,12.5 0.5,13.17 0.5,14 Z"
          stroke={c} strokeWidth="1" strokeLinejoin="round" />
        <path d="M13.56,6.3 L12.94,6.61 C12.74,6.71 12.49,6.62 12.39,6.42 C12.34,6.3 12.34,6.17 12.39,6.06 L12.7,5.43 C12.83,5.16 12.83,4.84 12.7,4.56 L12.39,3.94 C12.29,3.74 12.38,3.49 12.58,3.39 C12.7,3.34 12.83,3.34 12.94,3.39 L13.56,3.7 C13.84,3.83 14.16,3.83 14.44,3.7 L15.06,3.39 C15.26,3.29 15.51,3.38 15.61,3.58 C15.66,3.7 15.66,3.83 15.61,3.94 L15.3,4.56 C15.17,4.84 15.17,5.16 15.3,5.43 L15.61,6.06 C15.71,6.26 15.62,6.51 15.42,6.61 C15.3,6.66 15.17,6.66 15.06,6.61 L14.44,6.3 C14.16,6.17 13.84,6.17 13.56,6.3 Z"
          fill="#8E6BF2" transform="translate(0,0)" />
      </g>
    </svg>
  );
}

function IcHome({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} height="17px" viewBox="0 0 14 17" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M1.64089354,5.09915803 L5.82515973,1.79528921 C6.55886122,1.21596338 7.59600385,1.22218293 8.32270461,1.81026652 L12.3872109,5.09947385 C13.0910578,5.66906294 13.5,6.52607327 13.5,7.43151912 L13.5,13.5 C13.5,15.1568542 12.1568542,16.5 10.5,16.5 L3.5,16.5 C1.84314575,16.5 0.5,15.1568542 0.5,13.5 L0.5,7.45366927 C0.5,6.53560679 0.920364067,5.66808332 1.64089354,5.09915803 Z"
        stroke={c} strokeWidth="1" />
      <path d="M6.56369294,11.3042666 L5.93933983,11.607012 C5.73613227,11.7055462 5.49152222,11.6206918 5.39298799,11.4174842 C5.33835591,11.3048163 5.33835591,11.1733281 5.39298799,11.0606602 L5.6957334,10.4363071 C5.82933629,10.1607773 5.82933629,9.83922271 5.6957334,9.56369294 L5.39298799,8.93933983 C5.29445375,8.73613227 5.37930824,8.49152222 5.5825158,8.39298799 C5.69518375,8.33835591 5.82667188,8.33835591 5.93933983,8.39298799 L6.56369294,8.6957334 C6.83922271,8.82933629 7.16077729,8.82933629 7.43630706,8.6957334 L8.06066017,8.39298799 C8.26386773,8.29445375 8.50847778,8.37930824 8.60701201,8.5825158 C8.66164409,8.69518375 8.66164409,8.82667188 8.60701201,8.93933983 L8.3042666,9.56369294 C8.17066371,9.83922271 8.17066371,10.1607773 8.3042666,10.4363071 L8.60701201,11.0606602 C8.70554625,11.2638677 8.62069176,11.5084778 8.4174842,11.607012 C8.30481625,11.6616441 8.17332812,11.6616441 8.06066017,11.607012 L7.43630706,11.3042666 C7.16077729,11.1706637 6.83922271,11.1706637 6.56369294,11.3042666 Z"
        fill="#8E6BF2" transform="translate(7,10) rotate(-45) translate(-7,-10)" />
    </svg>
  );
}

function IcPlan({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M9 9C6.83 10.67 5.34 13.16 5 16M12 26.66C13.09 27.11 14.26 27.35 15.49 27.35C16.72 27.35 17.9 27.1 19 26.65M25 16C24.65 13.16 23.16 10.67 21 9"
        stroke={c} strokeWidth="1.5" strokeLinecap="round" />
      <path d="M15.18 10C17.11 10 18.68 8.43 18.68 6.5C18.68 4.57 17.11 3 15.18 3C13.24 3 11.68 4.57 11.68 6.5C11.68 8.43 13.24 10 15.18 10Z"
        stroke={c} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M5.5 25C7.43 25 9 23.43 9 21.5C9 19.57 7.43 18 5.5 18C3.57 18 2 19.57 2 21.5C2 23.43 3.57 25 5.5 25Z"
        stroke={c} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M24.5 25C26.43 25 28 23.43 28 21.5C28 19.57 26.43 18 24.5 18C22.57 18 21 19.57 21 21.5C21 23.43 22.57 25 24.5 25Z"
        stroke={c} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
      <path fillRule="evenodd" clipRule="evenodd"
        d="M16.25 18.86L15.6 20.72C15.51 20.98 15.23 21.12 14.97 21.03C14.82 20.98 14.71 20.86 14.66 20.72L14.02 18.86C13.92 18.57 13.69 18.35 13.4 18.25L11.54 17.6C11.28 17.51 11.14 17.23 11.23 16.97C11.29 16.82 11.4 16.71 11.54 16.66L13.4 16.01C13.69 15.91 13.92 15.69 14.02 15.4L14.66 13.54C14.75 13.28 15.03 13.14 15.3 13.23C15.44 13.28 15.55 13.4 15.6 13.54L16.25 15.4C16.35 15.69 16.58 15.91 16.86 16.01L18.72 16.66C18.98 16.75 19.12 17.03 19.03 17.29C18.98 17.44 18.86 17.55 18.72 17.6L16.86 18.25C16.58 18.35 16.35 18.57 16.25 18.86Z"
        fill="#8E6BF2" />
    </svg>
  );
}

function IcAnalysis({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 15 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M8.5,14.5 L3.5,14.5 C1.84,14.5 0.5,13.16 0.5,11.5 L0.5,3.5 C0.5,1.84 1.84,0.5 3.5,0.5 L9.5,0.5 C11.16,0.5 12.5,1.84 12.5,3.5 L12.5,8.5"
        stroke={c} strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M3.5,9.5 L4.91,7.38 C5.22,6.92 5.84,6.8 6.3,7.1 L6.65,7.37 C7.1,7.7 7.72,7.61 8.05,7.17 L9.5,5"
        stroke={c} strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M11.56,14.3 L10.94,14.61 C10.74,14.71 10.49,14.62 10.39,14.42 C10.34,14.3 10.34,14.17 10.39,14.06 L10.7,13.44 C10.83,13.16 10.83,12.84 10.7,12.56 L10.39,11.94 C10.29,11.74 10.38,11.49 10.58,11.39 C10.7,11.34 10.83,11.34 10.94,11.39 L11.56,11.7 C11.84,11.83 12.16,11.83 12.44,11.7 L13.06,11.39 C13.26,11.29 13.51,11.38 13.61,11.58 C13.66,11.7 13.66,11.83 13.61,11.94 L13.3,12.56 C13.17,12.84 13.17,13.16 13.3,13.44 L13.61,14.06 C13.71,14.26 13.62,14.51 13.42,14.61 C13.3,14.66 13.17,14.66 13.06,14.61 L12.44,14.3 C12.16,14.17 11.84,14.17 11.56,14.3 Z"
        fill="#8E6BF2" />
    </svg>
  );
}

function IcDocs({ size = 16, c = 'currentColor' }) {
  /* DocsIcon 路径坐标系有 y-2 偏移（来自 Figma 导出），用 wrapper translate 修正 */
  return (
    <svg width={size} viewBox="0 0 15 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g transform="translate(0,-2)">
        <path d="M8,3.5 L3.5,3.5 C1.84314575,3.5 0.5,4.84314575 0.5,6.5 L0.5,14.5 C0.5,16.1568542 1.84314575,17.5 3.5,17.5 L9.5,17.5 C11.1568542,17.5 12.5,16.1568542 12.5,14.5 L12.5,9 L12.5,9"
          stroke={c} strokeLinecap="round" strokeLinejoin="round" />
        <line x1="3.5" y1="8.5" x2="9.5" y2="8.5" stroke={c} strokeLinecap="round" strokeLinejoin="round" />
        <line x1="3.5" y1="11.5" x2="6.5" y2="11.5" stroke={c} strokeLinecap="round" strokeLinejoin="round" />
        <path d="M11.5636929,6.3042666 L10.9393398,6.60701201 C10.7361323,6.70554625 10.4915222,6.62069176 10.392988,6.4174842 C10.3383559,6.30481625 10.3383559,6.17332812 10.392988,6.06066017 L10.6957334,5.43630706 C10.8293363,5.16077729 10.8293363,4.83922271 10.6957334,4.56369294 L10.392988,3.93933983 C10.2944538,3.73613227 10.3793082,3.49152222 10.5825158,3.39298799 C10.6951837,3.33835591 10.8266719,3.33835591 10.9393398,3.39298799 L11.5636929,3.6957334 C11.8392227,3.82933629 12.1607773,3.82933629 12.4363071,3.6957334 L13.0606602,3.39298799 C13.2638677,3.29445375 13.5084778,3.37930824 13.607012,3.5825158 C13.6616441,3.69518375 13.6616441,3.82667188 13.607012,3.93933983 L13.3042666,4.56369294 C13.1706637,4.83922271 13.1706637,5.16077729 13.3042666,5.43630706 L13.607012,6.06066017 C13.7055462,6.26386773 13.6206918,6.50847778 13.4174842,6.60701201 C13.3048163,6.66164409 13.1733281,6.66164409 13.0606602,6.60701201 L12.4363071,6.3042666 C12.1607773,6.17066371 11.8392227,6.17066371 11.5636929,6.3042666 Z"
          fill="#8E6BF2" transform="translate(12,5) rotate(-45) translate(-12,-5)" />
      </g>
    </svg>
  );
}

function IcChat({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M12.5,10.5 C14.1568542,10.5 15.5,9.15685425 15.5,7.5 L15.5,3.5 C15.5,1.84314575 14.1568542,0.5 12.5,0.5 L6.5,0.5 C4.84314575,0.5 3.5,1.84314575 3.5,3.5"
        stroke={c} strokeLinecap="round" strokeLinejoin="round" />
      <path d="M0.5,6.5 L0.5,10.5 C0.5,12.1568542 1.84314575,13.5 3.5,13.5 L5,13.5 L5,13.5 L6.5,15.5 L8,13.5 L9.5,13.5 C11.1568542,13.5 12.5,12.1568542 12.5,10.5 L12.5,6.5 C12.5,4.84314575 11.1568542,3.5 9.5,3.5 L3.5,3.5 C1.84314575,3.5 0.5,4.84314575 0.5,6.5 Z"
        stroke={c} strokeLinecap="round" strokeLinejoin="round" />
      <path d="M6.06633363,9.80690728 L5.44198052,10.1096527 C5.23877296,10.2081869 4.99416291,10.1233324 4.89562867,9.92012489 C4.8409966,9.80745694 4.8409966,9.67596881 4.89562867,9.56330086 L5.19837409,8.93894775 C5.33197697,8.66341798 5.33197697,8.3418634 5.19837409,8.06633363 L4.89562867,7.44198052 C4.79709444,7.23877296 4.88194893,6.99416291 5.08515649,6.89562867 C5.19782444,6.8409966 5.32931257,6.8409966 5.44198052,6.89562867 L6.06633363,7.19837409 C6.3418634,7.33197697 6.66341798,7.33197697 6.93894775,7.19837409 L7.56330086,6.89562867 C7.76650841,6.79709444 8.01111847,6.88194893 8.1096527,7.08515649 C8.16428477,7.19782444 8.16428477,7.32931257 8.1096527,7.44198052 L7.80690728,8.06633363 C7.6733044,8.3418634 7.6733044,8.66341798 7.80690728,8.93894775 L8.1096527,9.56330086 C8.20818694,9.76650841 8.12333244,10.0111185 7.92012489,10.1096527 C7.80745694,10.1642848 7.67596881,10.1642848 7.56330086,10.1096527 L6.93894775,9.80690728 C6.66341798,9.6733044 6.3418634,9.6733044 6.06633363,9.80690728 Z"
        fill="#8E6BF2" transform="translate(6.502641,8.502641) rotate(-45) translate(-6.502641,-8.502641)" />
    </svg>
  );
}

function IcMemory({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M8 1.5C5.51 1.5 3.5 3.51 3.5 6C3.5 7.24 4 8.37 4.82 9.18C5.02 9.38 5.13 9.65 5.13 9.93V11.33C5.13 11.7 5.43 12 5.8 12H10.2C10.57 12 10.87 11.7 10.87 11.33V9.93C10.87 9.65 10.98 9.38 11.18 9.18C12 8.37 12.5 7.24 12.5 6C12.5 3.51 10.49 1.5 8 1.5Z"
        stroke={c} strokeWidth="1.2" strokeLinejoin="round" />
      <path d="M6 12V13C6 13.55 6.45 14 7 14H9C9.55 14 10 13.55 10 13V12"
        stroke={c} strokeWidth="1.2" strokeLinecap="round" />
      <path d="M6.5 6.5L7.5 7.5L9.5 5.5" stroke={c} strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  );
}

function IcScan({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g transform="translate(1,1)" stroke={c} strokeWidth="1" strokeLinecap="round">
        <path d="M4.5,0 L3,0 C1.34,0 0,1.34 0,3 L0,4.5" strokeLinejoin="round" />
        <path d="M12,0 L10.5,0 C8.84,0 7.5,1.34 7.5,3 L7.5,4.5" strokeLinejoin="round" transform="translate(9.75,2.25) rotate(-270) translate(-9.75,-2.25)" />
        <path d="M12,7.5 L10.5,7.5 C8.84,7.5 7.5,8.84 7.5,10.5 L7.5,12" strokeLinejoin="round" transform="translate(9.75,9.75) rotate(-180) translate(-9.75,-9.75)" />
        <path d="M4.5,7.5 L3,7.5 C1.34,7.5 0,8.84 0,10.5 L0,12" strokeLinejoin="round" transform="translate(2.25,9.75) rotate(-90) translate(-2.25,-9.75)" />
        <line x1="3" y1="6" x2="9" y2="6" />
      </g>
    </svg>
  );
}

function IcSettings({ size = 16, c = 'currentColor' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 14 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g transform="translate(0,1)" stroke={c} strokeWidth="1">
        <path d="M8.5,0.87 L11.56,2.63 C12.49,3.17 13.06,4.16 13.06,5.23 L13.06,8.77 C13.06,9.84 12.49,10.83 11.56,11.37 L8.5,13.13 C7.57,13.67 6.43,13.67 5.5,13.13 L2.44,11.37 C1.51,10.83 0.94,9.84 0.94,8.77 L0.94,5.23 C0.94,4.16 1.51,3.17 2.44,2.63 L5.5,0.87 C6.43,0.33 7.57,0.33 8.5,0.87 Z" />
        <circle cx="7" cy="7" r="2.5" />
      </g>
    </svg>
  );
}

function IcSearch({ size = 14, c = '#9D9D9D' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
      <circle cx="7.5" cy="7.5" r="6" stroke={c} strokeWidth="1.3" />
      <line x1="12.2" y1="12.2" x2="15" y2="15" stroke={c} strokeWidth="1.3" strokeLinecap="round" />
    </svg>
  );
}

function IcPanel({ size = 16, c = '#333329' }) {
  return (
    <svg width={size} height={size} viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path fillRule="evenodd" clipRule="evenodd"
        d="M1 7V14C1 15.6569 2.27245 17 3.84211 17H16.1579C17.7275 17 19 15.6569 19 14V7C19 5.34315 17.7275 4 16.1579 4H3.84211C2.27245 4 1 5.34315 1 7Z"
        stroke={c} strokeWidth="1.2" strokeLinejoin="round" />
      <path d="M8 4V17" stroke={c} strokeWidth="1.2" strokeLinejoin="round" />
      <path d="M3 7H6" stroke={c} strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M3 10H6" stroke={c} strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  );
}

function IcChevronRight({ size = 14, c = '#9D9D9D', rotate = 0 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"
      style={{ transform: `rotate(${rotate}deg)`, transition: 'transform 0.2s' }}>
      <path d="M6 4l4 4-4 4" stroke={c} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  );
}

function IcUserAvatar({ size = 36 }) {
  /* 浣熊吉祥物头像（紫色圆底 + 黑色浣熊剪影） */
  return (
    <svg width={size} height={size} viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
      <circle cx="18" cy="18" r="18" fill="#E8DEFF" />
      {/* 浣熊头身 */}
      <ellipse cx="18" cy="20" rx="9" ry="8" fill="#2A2A2A" />
      {/* 双耳 */}
      <circle cx="11.5" cy="13.5" r="3" fill="#2A2A2A" />
      <circle cx="24.5" cy="13.5" r="3" fill="#2A2A2A" />
      {/* 面罩浅色区 */}
      <path d="M11.5 19c1.8-1.2 4-1.8 6.5-1.8s4.7.6 6.5 1.8c-0.4 2.4-3.2 4.2-6.5 4.2s-6.1-1.8-6.5-4.2Z" fill="#E8DEFF" />
      {/* 眼睛 */}
      <circle cx="15" cy="19.5" r="1.1" fill="#2A2A2A" />
      <circle cx="21" cy="19.5" r="1.1" fill="#2A2A2A" />
      {/* 鼻头 */}
      <ellipse cx="18" cy="22" rx="1" ry="0.7" fill="#2A2A2A" />
    </svg>
  );
}

/* ─────────────────────────────────────────────
   历史会话占位数据
   ───────────────────────────────────────────── */
const HISTORY_ITEMS = [
  '分析第三季度用户留存数据',
  '帮我优化这份产品方案',
  '总结今天的会议纪要',
];

/* ─────────────────────────────────────────────
   AppShell — 完整 App 外壳（对齐 officev3 真实侧边栏）
   Props:
     activeNav: 'home'|'plan'|'analysis'|'docs'|'kb'|'datasource'|'memory'|'history'|'settings'
     overlayMenu: React node（弹出菜单，绝对定位）
     children: 主内容区
   ───────────────────────────────────────────── */
function AppShell({ activeNav = 'analysis', overlayMenu, children, isPro = false }) {
  const P = '#8E6BF2';
  const ACTIVE_BORDER = 'rgba(142,107,242,0.6)';
  const GRAD = 'linear-gradient(90deg, rgba(142,107,242,0.1) 0%, rgba(171,231,213,0.1) 100%)';

  /* 菜单项配置（对齐 officev3 AppSidebar：新建任务展开 + 知识库；底部 设置/官方社群/客户端下载） */
  const topItems = [
    { key: 'kb', label: '知识库', Icon: IcAsset },
  ];
  const childItems = [
    { key: 'home',     label: '主页',   Icon: IcHome },
    { key: 'plan',     label: '任务规划', Icon: IcPlan },
    { key: 'analysis', label: '数据分析', Icon: IcAnalysis },
    { key: 'docs',     label: '我的文档', Icon: IcDocs },
  ];
  const isChildActive = childItems.some(i => i.key === activeNav);

  /* 导航项内联样式 */
  function navStyle(active) {
    return {
      display: 'flex', alignItems: 'center',
      padding: '8px 16px', borderRadius: 12,
      border: `1px solid ${active ? ACTIVE_BORDER : 'transparent'}`,
      background: active ? GRAD : 'transparent',
      cursor: 'pointer',
      userSelect: 'none',
    };
  }
  function navChildStyle(active) {
    return {
      display: 'flex', alignItems: 'center',
      padding: '6px 16px', borderRadius: 12,
      border: `1px solid ${active ? ACTIVE_BORDER : 'transparent'}`,
      background: active ? GRAD : 'transparent',
      cursor: 'pointer',
      userSelect: 'none',
    };
  }
  const iconBox = { width: 24, flexShrink: 0, display: 'flex', alignItems: 'center' };
  const labelStyle = {
    flex: 1, fontSize: 14, color: '#0d0d0d',
    letterSpacing: '0.35px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
  };
  const subLabelStyle = { ...labelStyle, fontSize: 13 };
  const sep = {
    width: '100%', height: 1, background: '#E6E6E6',
    margin: '12px 0',
    flexShrink: 0,
  };

  return (
    <div style={{
      width: 880, height: 620,
      background: '#FAFAFA',
      display: 'flex', overflow: 'hidden',
      fontFamily: '"PingFang SC", Inter, -apple-system, sans-serif',
      position: 'relative',
    }}>
      {/* ── 左侧边栏 280px ── */}
      <div style={{
        width: 280, flexShrink: 0,
        background: '#F7F7F7',
        display: 'flex', flexDirection: 'column',
        overflow: 'hidden',
      }}>
        {/* 内容区 px-4 */}
        <div style={{ padding: '0 16px', display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>

          {/* ── Header: Logo + 搜索 ── */}
          <div style={{ paddingTop: 16, paddingBottom: 16, display: 'flex', flexDirection: 'column', gap: 20, flexShrink: 0 }}>
            {/* Logo 行（真实 office-new-logo.svg 内联） */}
            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '0 8px' }}>
              <div style={{ cursor: 'pointer', display: 'flex', alignItems: 'center' }}>
                <svg width="121" height="32" viewBox="0 0 121 32" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <g clipPath="url(#logo-clip0)">
                  <g clipPath="url(#logo-clip1)">
                  <g>
                  <g>
                  <g>
                  <g>
                  <g>
                  <path d="M59.6886 17.8477C61.2611 17.8477 62.5359 19.1069 62.5359 20.6602C62.5359 21.9882 61.6041 23.1012 60.3512 23.3962L63.3403 27.3818H60.6053L57.867 23.5385L57.8671 27.3818H55.2961V17.8477H59.6886ZM58.9966 19.5956H57.8703V21.8202H58.9966C59.6185 21.8202 60.1226 21.3222 60.1226 20.7079C60.1226 20.0936 59.6185 19.5956 58.9966 19.5956Z" fill="black"/>
                  <path d="M66.0241 27.3818H63.45L66.7204 17.8522L66.7188 17.8477H69.457L69.4553 17.8522L72.7259 27.3818H70.1518L69.5795 25.7926H66.5962L66.0241 27.3818ZM68.0878 21.65L67.34 23.7269H68.8357L68.0878 21.65Z" fill="black"/>
                  <path d="M114.919 22.5116L114.919 27.3818H112.345V17.8477H114.919L118.298 22.7177L118.298 17.8477H120.872V27.3818H118.298L114.919 22.5116Z" fill="black"/>
                  <path d="M97.7049 17.5298C100.459 17.5298 102.692 19.8064 102.692 22.6147C102.692 25.423 100.459 27.6996 97.7049 27.6996C94.9504 27.6996 92.7175 25.423 92.7175 22.6147C92.7175 19.8064 94.9504 17.5298 97.7049 17.5298ZM97.7049 19.9293C96.3721 19.9293 95.2917 21.1316 95.2917 22.6147C95.2917 24.0978 96.3721 25.3001 97.7049 25.3001C99.0377 25.3001 100.118 24.0978 100.118 22.6147C100.118 21.1316 99.0377 19.9293 97.7049 19.9293Z" fill="black"/>
                  <path d="M106.393 17.5298C109.147 17.5298 111.38 19.8064 111.38 22.6147C111.38 25.423 109.147 27.6996 106.393 27.6996C103.638 27.6996 101.405 25.423 101.405 22.6147C101.405 19.8064 103.638 17.5298 106.393 17.5298ZM106.393 19.9293C105.06 19.9293 103.979 21.1316 103.979 22.6147C103.979 24.0978 105.06 25.3001 106.393 25.3001C107.725 25.3001 108.806 24.0978 108.806 22.6147C108.806 21.1316 107.725 19.9293 106.393 19.9293Z" fill="black"/>
                  <path d="M77.6428 17.5298C79.6076 17.5298 81.3052 18.7032 82.1066 20.4044L79.7468 21.2369C79.3253 20.4536 78.5552 19.9293 77.675 19.9293C76.3422 19.9293 75.2617 21.1316 75.2617 22.6147C75.2617 24.0978 76.3422 25.3001 77.675 25.3001C78.5552 25.3001 79.3253 24.7758 79.7469 23.9924L82.1067 24.8249C81.3053 26.5261 79.6076 27.6996 77.6428 27.6996C74.9061 27.6996 72.6876 25.423 72.6876 22.6147C72.6876 19.8064 74.9061 17.5298 77.6428 17.5298Z" fill="black"/>
                  <path d="M87.6014 17.5298C89.5662 17.5298 91.2639 18.7032 92.0653 20.4044L89.7055 21.2369C89.2839 20.4536 88.5138 19.9293 87.6336 19.9293C86.3008 19.9293 85.2204 21.1316 85.2204 22.6147C85.2204 24.0978 86.3008 25.3001 87.6336 25.3001C88.5138 25.3001 89.2839 24.7758 89.7055 23.9924L92.0653 24.8249C91.2639 26.5261 89.5662 27.6996 87.6014 27.6996C84.8648 27.6996 82.6462 25.423 82.6462 22.6147C82.6462 19.8064 84.8648 17.5298 87.6014 17.5298Z" fill="black"/>
                  </g>
                  </g>
                  <g>
                  <g>
                  <path d="M58.8933 4.17389C61.6477 4.17389 63.8806 6.45046 63.8806 9.25875C63.8806 12.067 61.6477 14.3436 58.8933 14.3436C56.1388 14.3436 53.9059 12.067 53.9059 9.25875C53.9059 6.45046 56.1388 4.17389 58.8933 4.17389ZM58.8933 6.57331C57.5605 6.57331 56.48 7.77562 56.48 9.25875C56.48 10.7419 57.5605 11.9442 58.8933 11.9442C60.226 11.9442 61.3065 10.7419 61.3065 9.25875C61.3065 7.77562 60.226 6.57331 58.8933 6.57331Z" fill="black"/>
                  <path d="M89.5897 4.17389C91.5545 4.17389 93.2521 5.34729 94.0535 7.04843L91.6937 7.88097C91.2722 7.09766 90.5021 6.57331 89.6219 6.57331C88.2891 6.57331 87.2086 7.77562 87.2086 9.25875C87.2086 10.7419 88.2891 11.9442 89.6219 11.9442C90.5021 11.9442 91.2722 11.4198 91.6938 10.6365L94.0536 11.469C93.2522 13.1702 91.5545 14.3436 89.5897 14.3436C86.853 14.3436 84.6345 12.067 84.6345 9.25875C84.6345 6.45046 86.853 4.17389 89.5897 4.17389Z" fill="black"/>
                  <path d="M71.2813 6.52562H67.7419V8.11464H70.7986V10.1804H67.7419V13.994H65.1677V4.4599H71.2813V6.52562Z" fill="black"/>
                  <path d="M79.0036 6.52562H75.4641V8.11464H78.5209V10.1804H75.4641V13.994H72.89V4.4599H79.0036V6.52562Z" fill="black"/>
                  <path d="M83.3474 4.4599V13.994H80.7733V4.4599H83.3474Z" fill="black"/>
                  <path d="M95.1885 13.994V4.4599H101.302V6.52562H97.7626V8.11464H100.98V10.1804H97.7626V11.9283H101.302V13.994H95.1885Z" fill="black"/>
                  </g>
                  </g>
                  </g>
                  <path d="M18.2058 5.97097L18.3297 5.95306C19.5849 5.77461 20.9296 5.68569 22.3639 5.68569C23.9732 5.68569 25.5803 5.79763 27.1847 6.02146C33.79 1.87723 37.8476 0.436857 39.7769 1.96598C41.6584 3.45727 41.356 6.69 39.2071 11.7222L39.3498 11.9083C39.9349 12.6768 40.4033 13.3622 40.7557 13.9674C41.1143 14.5831 41.4405 15.343 41.7384 16.2494C43.0376 15.8785 44.0754 16.1215 44.7012 17.1123C45.11 17.7593 45.1309 18.4898 44.7816 19.1895L44.7763 19.1998L44.7968 19.2053C45.7125 19.4586 46.2918 20.171 46.4019 21.3407L46.4073 21.4027C46.5432 23.1241 44.2483 25.7839 40.7192 27.8273C36.2483 30.4161 30.1832 31.951 22.7904 31.951C15.3577 31.951 9.51154 30.7598 5.39091 28.706C2.03662 27.0342 0.00500488 24.81 0.00500488 23.0003C0.00500488 21.8966 0.474392 21.0443 1.39064 20.5975L1.44266 20.5728L1.42912 20.5532C1.17093 20.1709 1.04219 19.7313 1.05624 19.2317L1.05791 19.1861C1.10675 18.104 1.69893 17.3491 2.60907 17.0395C2.93634 16.9281 3.29585 16.8804 3.64567 16.8874C3.97766 15.8125 4.35028 14.8627 4.76507 14.0373C5.20306 13.1657 5.72122 12.3602 6.31917 11.6216L6.30823 11.508C5.65912 4.7095 6.21436 1.10994 8.56032 0.203705C10.8635 -0.686023 13.9869 1.3047 18.2058 5.97097ZM23.0328 8.72719C28.8405 8.72719 32.3285 10.421 34.6815 12.6489C37.0344 14.8767 40.1962 20.2453 37.0459 21.0471L36.6579 21.1451C33.4778 21.9424 28.5241 23.0063 26.3795 21.2359C24.1456 19.3917 25.9457 16.6023 22.353 16.6023C20.6683 16.6023 20.1759 17.4515 19.8675 18.4517L19.8465 18.5209L19.826 18.5905L19.7961 18.6957L19.7669 18.8015L19.7382 18.9078L19.6716 19.1575L19.6173 19.3561C19.4097 20.0989 19.1432 20.8132 18.438 21.2359C17.2642 21.9394 14.2392 21.8442 11.7444 21.4905L9.83506 23.7387L8.98953 20.9277C8.60376 20.8118 8.31058 20.6945 8.14429 20.5835C5.86318 19.061 7.28993 16.2464 9.79065 13.0953C12.2914 9.94411 17.225 8.72719 23.0328 8.72719ZM24.2025 17.9051C24.5922 18.8122 23.3238 20.0558 22.4726 20.0558C21.6214 20.0558 20.2074 18.6275 20.7689 17.772C21.3304 16.9165 23.8128 16.998 24.2025 17.9051ZM15.0655 13.2805C13.3683 13.2805 11.9925 14.6396 11.9925 16.3161C11.9925 17.9926 13.3683 19.3517 15.0655 19.3517C16.7627 19.3517 18.1385 17.9926 18.1385 16.3161C18.1385 14.6396 16.7627 13.2805 15.0655 13.2805ZM29.7903 13.2805C28.0932 13.2805 26.7173 14.6396 26.7173 16.3161C26.7173 17.9926 28.0932 19.3517 29.7903 19.3517C31.4875 19.3517 32.8634 17.9926 32.8634 16.3161C32.8634 14.6396 31.4875 13.2805 29.7903 13.2805Z" fill="black"/>
                  </g>
                  </g>
                  </g>
                  </g>
                  <defs>
                    <clipPath id="logo-clip0"><rect width="121" height="32" fill="white"/></clipPath>
                    <clipPath id="logo-clip1"><rect width="121" height="32" fill="white"/></clipPath>
                  </defs>
                </svg>
              </div>
              <div style={{ cursor: 'pointer', display: 'flex', alignItems: 'center' }}>
                <IcPanel />
              </div>
            </div>

            {/* 搜索框（border 样式，对应 officev3 真实代码） */}
            <div style={{
              display: 'flex', alignItems: 'center', justifyContent: 'space-between',
              padding: '8px 16px', borderRadius: 12,
              border: '1px solid #E6E6E6', background: 'transparent',
              cursor: 'text',
            }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                <IcSearch />
                <span style={{ fontSize: 14, color: '#1E1E1E' }}>搜索</span>
              </div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 4, color: '#BBBBBB', fontSize: 12 }}>
                <span>⌘</span><span>K</span>
              </div>
            </div>
          </div>

          {/* ── 滚动中间区 ── */}
          <div style={{ flex: 1, overflow: 'auto', minHeight: 0 }}>
            {/* 主菜单 */}
            <div style={{ display: 'flex', flexDirection: 'column', gap: 2, marginBottom: 20 }}>

              {/* 主页 / 任务规划 / 数据分析 / 我的文档（平铺，无父级） */}
              {childItems.map(({ key, label, Icon }) => {
                const active = key === activeNav;
                return (
                  <div key={key} style={navStyle(active)}>
                    <div style={iconBox}><Icon size={16} c={active ? P : '#2A2A2A'} /></div>
                    <div style={{ ...labelStyle, color: active ? P : '#0d0d0d', fontWeight: active ? 500 : 400 }}>{label}</div>
                  </div>
                );
              })}

              {/* 知识库 */}
              {topItems.map(({ key, label, Icon }) => {
                const active = key === activeNav;
                return (
                  <div key={key} style={navStyle(active)}>
                    <div style={iconBox}><Icon size={16} c={active ? P : '#2A2A2A'} /></div>
                    <div style={{ ...labelStyle, color: active ? P : '#0d0d0d', fontWeight: active ? 500 : 400 }}>{label}</div>
                  </div>
                );
              })}
            </div>

            {/* 分割线 */}
            <div style={sep} />

            {/* 历史会话 */}
            <div style={{ display: 'flex', flexDirection: 'column', gap: 2, marginBottom: 16 }}>
              <div style={navStyle(activeNav === 'history')}>
                <div style={iconBox}><IcChat size={16} c={activeNav === 'history' ? P : '#2A2A2A'} /></div>
                <div style={{ ...labelStyle, color: activeNav === 'history' ? P : '#0d0d0d' }}>历史会话</div>
              </div>
              {/* 历史条目 */}
              <div style={{ marginLeft: 16, marginTop: 2, display: 'flex', flexDirection: 'column', gap: 1 }}>
                {HISTORY_ITEMS.map((title, i) => (
                  <div key={i} style={{
                    padding: '6px 16px', borderRadius: 12, cursor: 'pointer',
                    overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
                    fontSize: 12, color: '#9D9D9D',
                  }}>{title}</div>
                ))}
              </div>
            </div>
          </div>

          {/* ── 底部固定区 ── */}
          <div style={{ flexShrink: 0 }}>
            {/* 底部菜单项 */}
            <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
              <div style={navStyle(activeNav === 'settings')}>
                <div style={iconBox}><IcSettings size={16} c={activeNav === 'settings' ? P : '#2A2A2A'} /></div>
                <div style={{ ...labelStyle, color: activeNav === 'settings' ? P : '#0d0d0d' }}>设置</div>
              </div>
              <div style={navStyle(false)}>
                <div style={iconBox}>
                  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="#2A2A2A" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round">
                    <path d="M3 4.5h10v6.5a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 3 11V4.5Z" />
                    <path d="M5.5 7.5h5M5.5 9.5h3" />
                  </svg>
                </div>
                <div style={labelStyle}>官方社群</div>
              </div>
              <div style={navStyle(false)}>
                <div style={iconBox}>
                  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="#2A2A2A" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round">
                    <path d="M8 2v8M5 7l3 3 3-3" />
                    <path d="M3 13h10" />
                  </svg>
                </div>
                <div style={labelStyle}>客户端下载</div>
              </div>
            </div>

            {/* 分割线 */}
            <div style={{ ...sep, margin: '16px 0' }} />

            {/* UserCard */}
            <div style={{
              display: 'flex', alignItems: 'center', gap: 10,
              padding: '10px 16px', marginBottom: 14,
              borderRadius: 20, border: '1px solid transparent',
              cursor: 'pointer',
            }}>
              <IcUserAvatar size={36} />
              <div style={{ flex: 1, minWidth: 0 }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }}>
                  <span style={{ fontSize: 14, fontWeight: 700, color: P, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
                    RaccoonBoat
                  </span>
                  <span style={{
                    flexShrink: 0,
                    padding: '1px 8px', borderRadius: 999,
                    fontSize: 10.5, fontWeight: 600,
                    background: 'rgba(142,107,242,0.12)', color: P,
                    display: 'inline-flex', alignItems: 'center', gap: 2,
                  }}>
                    <svg width="10" height="10" viewBox="0 0 12 12" fill="none">
                      <path d="M11 1L1 5.5l4 1.2L10.2 2.5 6.5 8l1.3 3L11 1Z" fill={P} />
                    </svg>
                    {isPro ? '升级版' : '免费版'}
                  </span>
                </div>
                <div style={{ fontSize: 12, fontWeight: 500, color: '#9D9D9D', marginTop: 1 }}>
                  可用积分 <span style={{ color: '#1A1A1A', fontWeight: 600 }}>{isPro ? '1820' : '120'}</span>
                </div>
              </div>
            </div>
          </div>

        </div>{/* end px-4 wrapper */}
      </div>{/* end sidebar */}

      {/* ── 主内容区 ── */}
      <div style={{ flex: 1, overflow: 'hidden', display: 'flex', flexDirection: 'column', position: 'relative' }}>
        {children}
      </div>

      {/* ── 浮层（弹出菜单等，定位在 UserCard 上方） ── */}
      {overlayMenu && (
        <div style={{ position: 'absolute', bottom: 72, left: 8, zIndex: 300 }}>
          {overlayMenu}
        </div>
      )}
    </div>
  );
}
