/* Individual app screens for 셔틀아이디 */

// ---- BusInterior shared bg ----
const BusInterior = () => (
  <svg width="100%" height="100%" viewBox="0 0 350 280" preserveAspectRatio="xMidYMid slice">
    <defs>
      <linearGradient id="busBg" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#2d3239" />
        <stop offset="100%" stopColor="#0c0e11" />
      </linearGradient>
    </defs>
    <rect width="350" height="280" fill="url(#busBg)" />
    {[0, 1, 2, 3].map(row => (
      <g key={row} transform={`translate(0, ${40 + row * 50})`}>
        <rect x="20" y="0" width="60" height="38" rx="6" fill="#4a525c" />
        <rect x="90" y="0" width="60" height="38" rx="6" fill="#4a525c" />
        <rect x="200" y="0" width="60" height="38" rx="6" fill="#4a525c" />
        <rect x="270" y="0" width="60" height="38" rx="6" fill="#4a525c" />
      </g>
    ))}
  </svg>
);

const MapSvg = () => (
  <svg width="100%" height="100%" viewBox="0 0 350 200" preserveAspectRatio="xMidYMid slice">
    <rect width="350" height="200" fill="#EEF4F8" />
    <path d="M -20 60 Q 100 30 200 80 T 380 60" stroke="#DCE3E8" strokeWidth="14" fill="none" />
    <path d="M -20 140 Q 80 110 180 150 T 380 130" stroke="#DCE3E8" strokeWidth="10" fill="none" />
    <path d="M 60 -20 Q 80 100 140 220" stroke="#E3E8EC" strokeWidth="8" fill="none" />
    <path d="M 240 -20 Q 260 100 290 220" stroke="#E3E8EC" strokeWidth="8" fill="none" />
    <path d="M 40 160 Q 120 130 180 110 T 320 50" stroke="#FFD400" strokeWidth="5" fill="none" strokeLinecap="round" />
    <circle cx="40" cy="160" r="9" fill="#FFD400" stroke="#fff" strokeWidth="3" />
    <circle cx="320" cy="50" r="9" fill="#EF4444" stroke="#fff" strokeWidth="3" />
  </svg>
);

// ============ SCREEN: Home ============
const HomeScreen = () => (
  <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
    <StatusBar />
    <div style={{padding: '8px 24px 0', display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
      <div style={{fontSize: 22, fontWeight: 700, letterSpacing: '-0.5px'}}>셔틀아이디</div>
      <div style={{display: 'flex', alignItems: 'center', gap: 12}}>
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke={SID.text} strokeWidth="1.8">
          <path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9z" /><path d="M10 21a2 2 0 0 0 4 0" />
        </svg>
        <div style={{width: 32, height: 32, borderRadius: 16, background: SID.yellow, display: 'grid', placeItems: 'center', fontSize: 13, fontWeight: 700}}>김</div>
      </div>
    </div>
    <div style={{margin: '14px 20px 0', padding: '14px 18px', background: SID.yellowBanner, borderRadius: 14, display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
      <div>
        <div style={{fontSize: 11, color: SID.textSub, marginBottom: 2}}>셔틀아이디가 처음인 분들을 위한</div>
        <div style={{fontSize: 15, fontWeight: 700}}>이용 가이드</div>
      </div>
      <div style={{fontSize: 18, color: SID.textSub}}>›</div>
    </div>
    <div style={{margin: '14px 20px 0', padding: 22, border: `1px solid ${SID.border}`, borderRadius: 18}}>
      <div style={{display: 'flex', alignItems: 'center', gap: 8, marginBottom: 6}}>
        <div style={{fontSize: 12, color: SID.textMid, fontWeight: 600}}>오전 운행</div>
        <div style={{fontSize: 11, color: SID.textSub}}>곧 시작</div>
      </div>
      <div style={{fontSize: 40, fontWeight: 800, letterSpacing: '-1px', marginBottom: 4}}>08:30</div>
      <div style={{fontSize: 16, fontWeight: 600, marginBottom: 2}}>일산 1호차 등하원</div>
      <div style={{fontSize: 12, color: SID.textSub, marginBottom: 18}}>일산 차고지 → 한빛초등학교 · 23명 예정</div>
      <button style={{
        width: '100%', padding: '16px', background: SID.yellow, border: 'none', borderRadius: 12,
        fontSize: 16, fontWeight: 700, color: SID.text,
      }}>운행 시작하기</button>
    </div>
    <div style={{padding: '20px 20px 0'}}>
      <div style={{fontSize: 13, fontWeight: 700, color: SID.textMid, marginBottom: 12}}>주요 기능</div>
      <MenuRow icon="recognize" title="실시간 인식 (1인)" sub="화면 속 인물을 실시간으로 확인합니다." />
      <MenuRow icon="work" title="업무 기록" sub="탑승·하차 기록을 작성합니다." />
      <MenuRow icon="data" title="데이터 관리" sub="촬영된 데이터를 확인·전송합니다." />
    </div>
    <div style={{flex: 1}} />
    <BottomNav active="home" />
  </div>
);

// ============ SCREEN: Multi-face Recognition (light) ============
const RecognitionScreen = () => (
  <div style={{height: '100%', background: SID.dark, position: 'relative', overflow: 'hidden'}}>
    <StatusBar dark />
    <div style={{padding: '0 20px', display: 'flex', alignItems: 'center', gap: 10, height: 44}}>
      <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#fff" strokeWidth="2" strokeLinecap="round">
        <path d="M9 18l-6-6 6-6" /><path d="M3 12h18" />
      </svg>
      <div style={{color: '#fff', fontSize: 16, fontWeight: 600, flex: 1}}>3명 인식 · 멀티 모드</div>
      <div style={{display: 'flex', alignItems: 'center', gap: 6, color: '#86EFAC', fontSize: 13, fontWeight: 700}}>
        <div style={{width: 8, height: 8, borderRadius: 4, background: '#22C55E'}} />LIVE
      </div>
    </div>
    {/* Camera viewfinder — matches real app's warm dark camera feed */}
    <div style={{
      margin: '12px 20px 0', height: 540, borderRadius: 18, position: 'relative',
      background: '#1A1612',
      backgroundImage: 'radial-gradient(ellipse at 35% 25%, rgba(86,70,40,0.35) 0%, transparent 55%), radial-gradient(ellipse at 70% 80%, rgba(40,30,18,0.5) 0%, transparent 50%), linear-gradient(180deg, #221C16 0%, #100C09 100%)',
      overflow: 'hidden',
    }}>
      {/* Corner scanning brackets */}
      <CornerBracket x={16} y={16} dir="tl" />
      <CornerBracket x={16} y={16} dir="tr" />
      <CornerBracket x={16} y={16} dir="bl" />
      <CornerBracket x={16} y={16} dir="br" />
      {/* Recognition badge */}
      <div style={{
        position: 'absolute', top: 16, left: 16,
        padding: '8px 14px', background: 'rgba(34,197,94,0.18)', border: '1px solid rgba(34,197,94,0.5)', borderRadius: 10,
        color: '#86EFAC', fontSize: 13, fontWeight: 700,
        display: 'flex', alignItems: 'center', gap: 8,
      }}>
        <div style={{width: 8, height: 8, borderRadius: 4, background: '#22C55E'}} />
        인식 (3명)
      </div>
      {/* Faces */}
      <FaceMarker top={86} left={56} name="김민준" pct="96%" />
      <FaceMarker top={130} left={205} name="이서연" pct="93%" />
      <FaceMarker top={310} left={120} name="박지훈" pct="91%" />
    </div>

    {/* Name list */}
    <div style={{margin: '14px 20px 0', display: 'flex', flexDirection: 'column', gap: 6}}>
      {[{n: '김민준', p: 96}, {n: '이서연', p: 93}, {n: '박지훈', p: 91}].map(p => (
        <div key={p.n} style={{padding: '8px 12px', background: 'rgba(34,197,94,0.18)', border: '1px solid rgba(34,197,94,0.4)', borderRadius: 8, color: '#86EFAC', fontSize: 12, fontWeight: 600, display: 'flex', justifyContent: 'space-between'}}>
          <span>● {p.n}</span><span>{p.p}%</span>
        </div>
      ))}
    </div>

    <div style={{position: 'absolute', bottom: 90, left: 0, right: 0, padding: '0 20px'}}>
      <div style={{
        background: 'rgba(255,255,255,0.06)', backdropFilter: 'blur(20px)',
        border: '1px solid rgba(255,255,255,0.08)', borderRadius: 18, padding: '14px 14px',
        display: 'flex', justifyContent: 'space-around', alignItems: 'center',
      }}>
        <StatCol n="3" l="탑승" color="#22C55E" />
        <StatCol n="12" l="예정" color="#fff" />
        <StatCol n="9" l="대기" color="#9CA3AF" />
        <div style={{display: 'grid', placeItems: 'center', width: 44, height: 44, background: SID.yellow, borderRadius: 22}}>
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke={SID.text} strokeWidth="2.4" strokeLinecap="round">
            <path d="M5 12h14M12 5l7 7-7 7" />
          </svg>
        </div>
      </div>
    </div>
  </div>
);

const CornerBracket = ({x, y, dir}) => {
  const positions = {
    tl: {top: y, left: x, transform: 'rotate(0deg)'},
    tr: {top: y, right: x, transform: 'rotate(90deg)'},
    bl: {bottom: y, left: x, transform: 'rotate(-90deg)'},
    br: {bottom: y, right: x, transform: 'rotate(180deg)'},
  };
  return (
    <div style={{position: 'absolute', ...positions[dir]}}>
      <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" opacity="0.45">
        <path d="M 4 12 L 4 4 L 12 4" />
      </svg>
    </div>
  );
};

const FaceMarker = ({top, left, name, pct}) => (
  <div style={{position: 'absolute', top, left}}>
    <div style={{
      width: 76, height: 76, borderRadius: '50%',
      background: 'rgba(0,0,0,0.5)',
      border: `3px solid #22C55E`,
      boxShadow: `0 0 0 4px rgba(34,197,94,0.2)`,
      display: 'grid', placeItems: 'center',
      overflow: 'hidden',
    }}>
      <svg width={42} height={42} viewBox="0 0 24 24" fill="#fff" opacity="0.9">
        <circle cx="12" cy="8" r="4" /><path d="M4 21a8 8 0 0 1 16 0" />
      </svg>
    </div>
    <div style={{
      marginTop: -10, marginLeft: -8, padding: '3px 10px',
      background: '#22C55E', color: '#0F1115', borderRadius: 99, fontSize: 11, fontWeight: 700,
      textAlign: 'center', width: 'fit-content',
      display: 'flex', alignItems: 'center', gap: 5,
      boxShadow: '0 2px 6px rgba(0,0,0,0.3)',
    }}>{name}<span style={{opacity: 0.7}}>{pct}</span></div>
  </div>
);

const StatCol = ({n, l, color}) => (
  <div style={{textAlign: 'center', minWidth: 50}}>
    <div style={{fontSize: 22, fontWeight: 700, color}}>{n}</div>
    <div style={{fontSize: 10, color: '#9CA3AF', marginTop: 2}}>{l}</div>
  </div>
);

// ============ SCREEN: 운행 종료 (residual check completed) ============
const CompletedScreen = () => (
  <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
    <StatusBar />
    <div style={{padding: '0 20px', display: 'flex', alignItems: 'center', gap: 10, height: 44}}>
      <Caret /><div style={{fontSize: 16, fontWeight: 600}}>운행 종료</div>
    </div>
    <div style={{margin: '16px 20px 0', padding: '14px 16px', background: '#FEF2F2', borderRadius: 12, display: 'flex', gap: 10, alignItems: 'flex-start'}}>
      <div style={{color: SID.red, fontSize: 18, lineHeight: 1}}>⚠</div>
      <div>
        <div style={{fontSize: 12, color: SID.red, fontWeight: 700, marginBottom: 2}}>안전 확인 절차</div>
        <div style={{fontSize: 12, color: SID.text, fontWeight: 600}}>차 안에 남은 승객을 확인합니다</div>
      </div>
    </div>
    <div style={{margin: '20px 20px 0', position: 'relative', borderRadius: 18, overflow: 'hidden', height: 320, background: SID.dark}}>
      <BusInterior />
      <div style={{position: 'absolute', inset: 0, background: 'rgba(0,0,0,0.55)', display: 'grid', placeItems: 'center'}}>
        <div style={{textAlign: 'center'}}>
          <div style={{width: 90, height: 90, borderRadius: 45, background: SID.yellow, display: 'grid', placeItems: 'center', margin: '0 auto 14px', boxShadow: '0 8px 20px rgba(0,0,0,0.4)'}}>
            <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke={SID.text} strokeWidth="3.2" strokeLinecap="round" strokeLinejoin="round">
              <path d="M5 13l4 4L19 7" />
            </svg>
          </div>
          <div style={{color: '#fff', fontSize: 22, fontWeight: 800}}>잔류 확인 완료</div>
        </div>
      </div>
    </div>
    <div style={{margin: '14px 20px 0', fontSize: 12, color: SID.textSub, textAlign: 'center'}}>사진 3장 자동 촬영됨</div>
    <div style={{flex: 1}} />
    <div style={{padding: '0 20px 32px'}}>
      <button style={{width: '100%', padding: 16, background: SID.yellow, border: 'none', borderRadius: 12, fontSize: 16, fontWeight: 700, color: SID.text}}>확인 완료, 운행 종료</button>
    </div>
  </div>
);

// ============ SCREEN: 운행 상세 ============
const DriveDetailScreen = () => (
  <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
    <StatusBar />
    <div style={{padding: '0 20px', display: 'flex', alignItems: 'center', gap: 10, height: 44}}>
      <Caret /><div style={{fontSize: 16, fontWeight: 600}}>운행 상세</div>
    </div>
    <div style={{padding: '14px 22px 0'}}>
      <div style={{fontSize: 12, color: SID.textSub, marginBottom: 6}}>2026.05.06 (수) · 08:30</div>
      <div style={{fontSize: 26, fontWeight: 800, letterSpacing: '-0.5px'}}>일산 1호차 등원</div>
    </div>
    <div style={{margin: '18px 20px 0', height: 200, borderRadius: 16, background: '#F8FAFC', overflow: 'hidden', position: 'relative', border: `1px solid ${SID.border}`}}>
      <MapSvg />
    </div>
    <div style={{margin: '18px 20px 0', padding: '18px 0', borderTop: `1px solid ${SID.border}`, borderBottom: `1px solid ${SID.border}`, display: 'flex', justifyContent: 'space-around'}}>
      <BigStat label="탑승" val="23명" />
      <BigStat label="운행시간" val="34분" />
      <BigStat label="거리" val="12km" />
    </div>
    <div style={{padding: '20px 20px 0'}}>
      <div style={{fontSize: 14, fontWeight: 700, marginBottom: 12}}>잔류 확인 사진</div>
      <div style={{display: 'flex', gap: 10}}>
        {[1, 2, 3].map(i => (
          <div key={i} style={{flex: 1, aspectRatio: '1/1.1', borderRadius: 10, background: SID.dark, position: 'relative', overflow: 'hidden'}}>
            <BusInterior />
            <div style={{position: 'absolute', bottom: 0, left: 0, right: 0, padding: '4px 8px', background: 'linear-gradient(transparent, rgba(0,0,0,0.7))', color: '#fff', fontSize: 10, fontWeight: 600}}>{i}/3 · 자동</div>
          </div>
        ))}
      </div>
    </div>
    <div style={{flex: 1}} />
    <BottomNav active="stats" />
  </div>
);

const BigStat = ({label, val}) => (
  <div style={{textAlign: 'center'}}>
    <div style={{fontSize: 11, color: SID.textSub, marginBottom: 4}}>{label}</div>
    <div style={{fontSize: 22, fontWeight: 800, letterSpacing: '-0.5px'}}>{val}</div>
  </div>
);

// ============ SCREEN: 인식 결과 보고서 ============
const ReportScreen = () => (
  <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
    <StatusBar />
    <div style={{padding: '0 20px', display: 'flex', alignItems: 'center', gap: 10, height: 44}}>
      <Caret /><div style={{fontSize: 16, fontWeight: 600}}>인식 결과 보고서</div>
    </div>
    <div style={{padding: '14px 20px 0'}}>
      <div style={{display: 'flex', gap: 8, marginBottom: 18}}>
        <SummaryStat label="인식" val="22명" />
        <SummaryStat label="주의" val="1명" />
        <SummaryStat label="미등록" val="1명" />
      </div>
      <div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: 12}}>
        <div style={{fontSize: 14, fontWeight: 700}}>상세</div>
        <div style={{fontSize: 11, color: SID.textSub}}>2026.05.06 등원</div>
      </div>
      <PersonRow init="박" name="박지훈" sub="A행 · 08:14 · 정확도 0.96" tag="인식됨" tagColor={SID.green} />
      <PersonRow init="김" name="김민서" sub="A행 · 08:16 · 정확도 0.92" tag="인식됨" tagColor={SID.green} />
      <PersonRow init="이" name="이서연" sub="A행 · 08:18 · 정확도 0.78" tag="주의" tagColor="#F59E0B" />
      <PersonRow init="미" name="미등록" sub="08:21" tag="미등록" tagColor={SID.red} />
      <PersonRow init="정" name="정하준" sub="B행 · 08:24 · 정확도 0.94" tag="인식됨" tagColor={SID.green} />
    </div>
    <div style={{flex: 1}} />
    <BottomNav active="stats" />
  </div>
);

const SummaryStat = ({label, val}) => (
  <div style={{flex: 1, padding: '14px 12px', background: SID.bgGray, borderRadius: 12}}>
    <div style={{fontSize: 11, color: SID.textSub, marginBottom: 4}}>{label}</div>
    <div style={{fontSize: 20, fontWeight: 800, letterSpacing: '-0.5px'}}>{val}</div>
  </div>
);

const PersonRow = ({init, name, sub, tag, tagColor}) => (
  <div style={{display: 'flex', alignItems: 'center', gap: 12, padding: '12px 0', borderBottom: `1px solid ${SID.border}`}}>
    <div style={{width: 36, height: 36, borderRadius: 18, background: SID.yellowSoft, display: 'grid', placeItems: 'center', fontSize: 13, fontWeight: 700}}>{init}</div>
    <div style={{flex: 1}}>
      <div style={{fontSize: 14, fontWeight: 600, marginBottom: 2}}>{name}</div>
      <div style={{fontSize: 11, color: SID.textSub}}>{sub}</div>
    </div>
    <div style={{padding: '4px 10px', borderRadius: 99, background: tagColor + '22', color: tagColor, fontSize: 11, fontWeight: 700}}>{tag}</div>
  </div>
);

// ============ SCREEN: 통계 dashboard ============
const StatsScreen = () => (
  <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
    <StatusBar />
    <div style={{padding: '12px 24px 0'}}>
      <div style={{fontSize: 22, fontWeight: 700}}>통계</div>
    </div>
    <div style={{margin: '18px 20px 0', padding: 20, border: `1px solid ${SID.border}`, borderRadius: 18}}>
      <div style={{fontSize: 12, color: SID.textSub, marginBottom: 4}}>이번 주 탑승객</div>
      <div style={{display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 18}}>
        <div style={{fontSize: 38, fontWeight: 800, letterSpacing: '-1px'}}>123</div>
        <div style={{fontSize: 16, fontWeight: 600, color: SID.text}}>명</div>
        <div style={{padding: '2px 8px', borderRadius: 6, background: '#DCFCE7', color: '#16A34A', fontSize: 11, fontWeight: 700}}>+8%</div>
      </div>
      <BarChart />
    </div>
    <div style={{padding: '22px 20px 0'}}>
      <div style={{fontSize: 13, fontWeight: 700, color: SID.textMid, marginBottom: 8}}>통계 메뉴</div>
      <MenuRow icon="data" title="운행 기록" sub="과거 운행 이력을 확인합니다." />
      <MenuRow icon="recognize" title="인식 결과 보고서" sub="얼굴 인식 정확도 결과를 봅니다." />
      <MenuRow icon="work" title="탑승 통계" sub="기간별 탑승 인원·노선을 분석합니다." />
    </div>
    <div style={{flex: 1}} />
    <BottomNav active="stats" />
  </div>
);

const BarChart = () => {
  const days = ['월', '화', '수', '목', '금', '토', '일'];
  const values = [18, 22, 28, 19, 25, 8, 3];
  const max = 30;
  return (
    <div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', height: 80, gap: 4}}>
      {days.map((d, i) => {
        const h = (values[i] / max) * 70;
        const highlight = i === 2;
        return (
          <div key={d} style={{flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6}}>
            <div style={{width: '70%', height: h, background: highlight ? SID.yellow : '#E5E7EB', borderRadius: 4}} />
            <div style={{fontSize: 10, color: SID.textSub}}>{d}</div>
          </div>
        );
      })}
    </div>
  );
};

// ============ SCREEN: 좌석 예약 ============
const SeatReservationScreen = () => {
  const available = new Set([5, 7, 10, 14, 15, 18, 20, 22, 24]);
  const numbers = {5: 5, 7: 7, 10: 10, 14: 14, 15: 15, 18: 18, 20: 20, 22: 22, 24: 25};
  return (
    <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
      <StatusBar />
      <div style={{padding: '0 20px', display: 'flex', alignItems: 'center', gap: 10, height: 44}}>
        <Caret /><div style={{fontSize: 16, fontWeight: 600}}>좌석 예약</div>
      </div>
      <div style={{padding: '14px 22px 0'}}>
        <div style={{fontSize: 12, color: SID.textSub, marginBottom: 4}}>노선</div>
        <div style={{fontSize: 18, fontWeight: 700}}>일산 1호차 등원 · 08:30</div>
      </div>
      <div style={{margin: '20px 20px 0', padding: 20, border: `1px solid ${SID.border}`, borderRadius: 18}}>
        <div style={{textAlign: 'right', fontSize: 11, color: SID.textSub, marginBottom: 14}}>← 운전석</div>
        <div style={{display: 'grid', gridTemplateColumns: '1fr 1fr 18px 1fr 1fr', gap: 8, maxWidth: 260, margin: '0 auto'}}>
          {Array.from({length: 25}, (_, i) => {
            const row = Math.floor(i / 5);
            const col = i % 5;
            if (col === 2) return <div key={`gap-${i}`} />;
            const isAvail = available.has(i);
            return (
              <div key={i} style={{
                aspectRatio: '1/1', background: isAvail ? SID.yellow : '#E5E7EB',
                borderRadius: 6, display: 'grid', placeItems: 'center',
                fontSize: 12, fontWeight: 700, color: isAvail ? SID.text : 'transparent',
              }}>{isAvail ? numbers[i] : ''}</div>
            );
          })}
        </div>
        <div style={{display: 'flex', gap: 14, justifyContent: 'center', marginTop: 18, fontSize: 11, color: SID.textSub}}>
          <div style={{display: 'flex', alignItems: 'center', gap: 6}}>
            <div style={{width: 14, height: 14, borderRadius: 4, background: SID.yellow}} />예약 가능
          </div>
          <div style={{display: 'flex', alignItems: 'center', gap: 6}}>
            <div style={{width: 14, height: 14, borderRadius: 4, background: '#E5E7EB'}} />이미 예약
          </div>
        </div>
      </div>
      <div style={{flex: 1}} />
      <div style={{padding: '0 20px 28px'}}>
        <button style={{width: '100%', padding: 16, background: SID.yellow, border: 'none', borderRadius: 12, fontSize: 16, fontWeight: 700, color: SID.text}}>예약 링크 공유</button>
      </div>
    </div>
  );
};

// ============ SCREEN: 운행 준비 ============
const PrepScreen = () => (
  <div style={{height: '100%', background: '#fff', display: 'flex', flexDirection: 'column'}}>
    <StatusBar />
    <div style={{padding: '0 20px', display: 'flex', alignItems: 'center', gap: 10, height: 44}}>
      <Caret /><div style={{fontSize: 16, fontWeight: 600}}>운행 준비</div>
    </div>
    <div style={{padding: '8px 22px 0'}}>
      <div style={{fontSize: 12, color: SID.textSub, marginBottom: 8}}>오전 운행 · 08:30</div>
      <div style={{fontSize: 28, fontWeight: 800, letterSpacing: '-0.5px'}}>일산 1호차 등하원</div>
    </div>
    <div style={{margin: '28px 20px 0', display: 'flex', flexDirection: 'column', gap: 18}}>
      <div style={{display: 'flex', alignItems: 'center', gap: 16}}>
        <div style={{width: 14, height: 14, borderRadius: 7, background: '#FFD400'}} />
        <div style={{flex: 1, fontSize: 16, fontWeight: 600}}>일산 차고지</div>
        <div style={{fontSize: 11, color: SID.textSub, fontWeight: 600}}>출발</div>
      </div>
      <div style={{borderLeft: `2px dashed ${SID.border}`, marginLeft: 7, height: 18}} />
      <div style={{display: 'flex', alignItems: 'center', gap: 16}}>
        <div style={{width: 14, height: 14, borderRadius: 7, background: '#EF4444'}} />
        <div style={{flex: 1, fontSize: 16, fontWeight: 600}}>한빛초등학교</div>
        <div style={{fontSize: 11, color: SID.textSub, fontWeight: 600}}>도착</div>
      </div>
    </div>
    <div style={{margin: '28px 20px 0', padding: '18px 16px', background: SID.yellowBanner, borderRadius: 14}}>
      <div style={{fontSize: 11, color: SID.textMid, marginBottom: 4, fontWeight: 600}}>운행 시작 전 확인사항</div>
      <div style={{fontSize: 15, fontWeight: 700, marginBottom: 8}}>스마트폰을 거치대에 놓으세요</div>
      <div style={{fontSize: 11, color: SID.textSub, lineHeight: 1.5}}>전면 카메라가 출입구를 향하도록 고정해 주세요.</div>
    </div>
    <div style={{flex: 1}} />
    <div style={{padding: '0 20px 28px'}}>
      <button style={{width: '100%', padding: 16, background: SID.yellow, border: 'none', borderRadius: 12, fontSize: 16, fontWeight: 700, color: SID.text}}>카메라 켜고 운행 시작</button>
    </div>
  </div>
);

Object.assign(window, {
  HomeScreen, RecognitionScreen, CompletedScreen, DriveDetailScreen,
  ReportScreen, StatsScreen, SeatReservationScreen, PrepScreen,
  BusInterior, MapSvg,
});
