<!-- @dsCard group="移动端" viewport="1100x720" name="移动端 UI Kit" subtitle="语音键盘（按住说话）+ 主 App 四屏 — 可交互，Light/Dark" -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dudu 移动端 UI Kit</title>
<link rel="stylesheet" href="../../styles.css">
<script src="https://unpkg.com/react@18.3.1/umd/react.development.js" integrity="sha384-hD6/rw4ppMLGNu3tX5cjIb+uRZ7UkRJ6BPkLpg4hAu/6onKUg4lLsHAs9EBPT82L" crossorigin="anonymous"></script>
<script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js" integrity="sha384-u6aeetuaXnQ38mYT8rp6sbXaQe3NL9t+IBXmnYxwkUI2Hw4bsp2Wvmx4yRQF1uAm" crossorigin="anonymous"></script>
<script src="https://unpkg.com/@babel/standalone@7.29.0/babel.min.js" integrity="sha384-m08KidiNqLdpJqLq95G/LEi8Qvjl/xUYll3QILypMoQ65QorJ9Lvtp2RXYGBFj1y" crossorigin="anonymous"></script>
<script src="../../_ds_bundle.js"></script>
<style>
  html, body { margin: 0; height: 100%; }
  body { font-family: var(--font-sans); }
  #root { height: 100%; }
  @keyframes dd-caret { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel" src="./MobileShared.jsx"></script>
<script type="text/babel" src="./KeyboardScreen.jsx"></script>
<script type="text/babel" src="./AppScreens.jsx"></script>
<script type="text/babel">
function Chip({ active, onClick, children }) {
  return (
    <button type="button" onClick={onClick} style={{
      height: 28, padding: '0 13px', borderRadius: 'var(--radius-full)', cursor: 'pointer', whiteSpace: 'nowrap',
      border: active ? '1px solid transparent' : '1px solid var(--border-1)',
      background: active ? 'var(--accent-soft)' : 'var(--surface-card)',
      color: active ? 'var(--accent-text)' : 'var(--text-2)',
      fontFamily: 'var(--font-sans)', fontSize: 'var(--text-xs)',
      fontWeight: active ? 'var(--weight-medium)' : 'var(--weight-regular)',
      transition: 'background var(--dur-fast) var(--ease-out)',
    }}>{children}</button>
  );
}

function MobileKit() {
  const [override, setOverride] = React.useState(null);   // null = 跟随系统
  const [systemDark, setSystemDark] = React.useState(
    window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
  );
  React.useEffect(() => {
    const mq = window.matchMedia('(prefers-color-scheme: dark)');
    const fn = (e) => setSystemDark(e.matches);
    mq.addEventListener('change', fn);
    return () => mq.removeEventListener('change', fn);
  }, []);
  const dark = override === null ? systemDark : override;
  const [account, setAccount] = React.useState('ok');   // 键盘状态
  const [appScreen, setAppScreen] = React.useState('onboarding');

  const APP_SCREENS = [
    ['onboarding', '启用引导'],
    ['login', '登录'],
    ['paywall', '购买时长'],
    ['profile', '我的'],
  ];

  return (
    <div data-theme={dark ? 'dark' : undefined} style={{
      height: '100%', display: 'flex', flexDirection: 'column',
      background: 'var(--bg-app)', transition: 'background var(--dur-base) var(--ease-out)',
    }}>
      {/* 顶栏 */}
      <div style={{
        display: 'flex', alignItems: 'center', gap: 14, padding: '12px 20px',
        borderBottom: '1px solid var(--border-1)', background: 'var(--surface-card)',
      }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 9, color: 'var(--text-1)', whiteSpace: 'nowrap' }}>
          <span style={{ color: 'var(--accent)', display: 'inline-flex' }}><DuduMLogo size={22} /></span>
          <span style={{ fontWeight: 'var(--weight-semibold)', fontSize: 'var(--text-base)', letterSpacing: 'var(--tracking-wide)' }}>dudu</span>
          <span style={{ fontSize: 'var(--text-sm)', color: 'var(--text-3)' }}>移动端 · iOS / Android</span>
        </span>
        <button type="button" onClick={() => setOverride(!dark)} aria-label="切换深浅模式" style={{
          marginLeft: 'auto', width: 32, height: 32, borderRadius: 'var(--radius-sm)',
          border: '1px solid var(--border-1)', background: 'var(--surface-card)', color: 'var(--text-2)',
          display: 'inline-flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
        }}>
          {dark ? (
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2"></path><path d="M12 20v2"></path><path d="m4.93 4.93 1.41 1.41"></path><path d="m17.66 17.66 1.41 1.41"></path><path d="M2 12h2"></path><path d="M20 12h2"></path><path d="m6.34 17.66-1.41 1.41"></path><path d="m19.07 4.93-1.41 1.41"></path></svg>
          ) : (
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"></path></svg>
          )}
        </button>
      </div>

      {/* 舞台：键盘 + 主 App 并排 */}
      <div style={{ flex: 1, display: 'flex', overflow: 'auto' }}>
        <div style={{ margin: 'auto', display: 'flex', gap: 56, alignItems: 'flex-start', padding: 28 }}>
          {/* 键盘扩展 */}
          <div style={{ display: 'flex', flexDirection: 'column', gap: 14, alignItems: 'center' }}>
            <div style={{ display: 'flex', gap: 6 }}>
              <Chip active={account === 'ok'} onClick={() => setAccount('ok')}>有余额</Chip>
              <Chip active={account === 'trial'} onClick={() => setAccount('trial')}>试用中</Chip>
              <Chip active={account === 'guest'} onClick={() => setAccount('guest')}>未登录</Chip>
              <Chip active={account === 'quota'} onClick={() => setAccount('quota')}>试用已用完</Chip>
            </div>
            <PhoneFrame>
              <KeyboardScreen account={account} key={account} />
            </PhoneFrame>
            <span style={{ fontSize: 'var(--text-xs)', color: 'var(--text-3)' }}>键盘扩展 — 按住麦克风条说话</span>
          </div>

          {/* 主 App */}
          <div style={{ display: 'flex', flexDirection: 'column', gap: 14, alignItems: 'center' }}>
            <div style={{ display: 'flex', gap: 6 }}>
              {APP_SCREENS.map(([key, label]) => (
                <Chip key={key} active={appScreen === key} onClick={() => setAppScreen(key)}>{label}</Chip>
              ))}
            </div>
            <PhoneFrame>
              {appScreen === 'onboarding' && <OnboardingScreen />}
              {appScreen === 'login' && <LoginScreen />}
              {appScreen === 'paywall' && <PaywallScreen />}
              {appScreen === 'profile' && <ProfileScreen />}
            </PhoneFrame>
            <span style={{ fontSize: 'var(--text-xs)', color: 'var(--text-3)' }}>主 App — 登录 / 购买 / 用量</span>
          </div>
        </div>
      </div>
    </div>
  );
}

ReactDOM.createRoot(document.getElementById('root')).render(<MobileKit />);
</script>
</body>
</html>
