/* MaXTerm 원격 조종 웹 (시안 docs/mockups/1111/G-remote.html의 휴대폰 화면) */
:root {
  --bg: #0e1016; --panel: #161925; --card: #1c2030; --field: #10121a; --line: #2a3044;
  --text: #eceef6; --muted: #8f98b0; --violet: #8b5cf6; --pink: #ec4899; --cyan: #38bdf8;
  --ok: #34d399; --warn: #fbbf24; --run: #60a5fa; --bad: #f87171;
  --mono: 'JetBrains Mono', D2Coding, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, 'Apple SD Gothic Neo', Pretendard, 'Noto Sans KR', sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
#app { display: flex; flex-direction: column; max-width: 560px; height: 100dvh; margin: 0 auto; padding-top: env(safe-area-inset-top); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.logo { display: inline-flex; align-items: center; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.logo .mk { height: 19px; margin-right: 8px; } /* 맥 앱 사이드바와 같은 X_ 마크 */
.logo .x { color: var(--pink); }
.logo .t { background: linear-gradient(90deg, var(--cyan), var(--violet), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top { flex: none; display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; }
.top .sp { flex: 1; }
.ib { display: grid; place-items: center; width: 40px; height: 40px; margin: -8px; border: 0; border-radius: 12px; background: none; color: #c5cae0; }
.body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
h1 { margin: 4px 0 8px; font-size: 19px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: 14px; background: linear-gradient(135deg, #8b5cf6, #c264ff); color: #fff; font-weight: 600; font-size: 15.5px; }
.btn.sub { min-height: 44px; border: 1px solid var(--line); background: none; color: #dfe3ee; font-weight: 500; }
.btn:disabled { opacity: 0.55; }
.btn + .btn { margin-top: 10px; }
.hint { margin: 12px 2px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.hint b { color: #dfe3ee; font-weight: 600; }
.err { margin: 12px 0; padding: 10px 12px; border: 1px solid rgba(248, 113, 113, 0.4); border-radius: 12px; background: rgba(248, 113, 113, 0.08); color: #fecaca; font-size: 13.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; border: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.07); color: #d5d9e6; font-size: 12.5px; white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.on { background: rgba(139, 92, 246, 0.22); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.d-attention { background: var(--warn); } .d-running { background: var(--run); } .d-done { background: var(--ok); } .d-idle { background: #4b5368; }

/* 기기 등록 */
.steps { display: grid; gap: 10px; margin: 6px 0 14px; }
.stp { display: flex; gap: 11px; align-items: flex-start; font-size: 13.5px; color: #d5d9e6; }
.stp > b { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 8px; background: rgba(139, 92, 246, 0.25); color: #d9c9ff; font: 700 12px var(--mono); }
.stp span b { color: #fff; font-weight: 600; }
.cam { position: relative; height: 252px; border-radius: 20px; background: radial-gradient(160px 120px at 30% 30%, #2a2f44, #14161f 70%); overflow: hidden; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam .fr { position: absolute; inset: 42px 62px; border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.45); pointer-events: none; }
.cam .fr::before, .cam .fr::after { content: ''; position: absolute; width: 30px; height: 30px; border: 3px solid #fff; }
.cam .fr::before { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.cam .fr::after { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.cam p { position: absolute; left: 0; right: 0; bottom: 12px; margin: 0; text-align: center; color: #fff; font-size: 13px; pointer-events: none; }
.cam .btn { position: absolute; left: 50%; top: 50%; width: auto; padding: 0 20px; transform: translate(-50%, -50%); }
textarea { display: block; width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--field); color: var(--text); font: inherit; font-size: 16px; resize: none; }
.code { display: flex; justify-content: center; gap: 8px; margin: 18px 0; font: 700 34px var(--mono); letter-spacing: 2px; }
.code span { padding: 8px 16px; border-radius: 12px; background: var(--field); }

/* 잠금 · 안내 */
.lock { display: grid; justify-items: center; gap: 14px; padding: 56px 10px 0; text-align: center; }
.lock .btn { margin-top: 0; }
.face { display: grid; place-items: center; width: 92px; height: 92px; border-radius: 28px; background: rgba(139, 92, 246, 0.16); color: #c9b8ff; }
.face svg { width: 46px; height: 46px; }
.lock h1 { margin: 4px 0 0; }
.lock .hint { max-width: 280px; margin: 0; }

/* 세션 목록 */
.mac { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 13.5px; }
.mac b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mac small { margin-left: auto; color: var(--ok); font-size: 12px; white-space: nowrap; }
.mac.off small { color: var(--warn); }
.sum { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.proj { display: flex; align-items: center; gap: 7px; margin: 14px 2px 6px; color: #c5cae0; font-size: 12.5px; font-weight: 600; }
.proj small { margin-left: auto; color: var(--muted); font-weight: 400; }
.ses { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; border-radius: 14px; background: var(--card); margin-bottom: 6px; text-align: left; }
.ses .w { flex: 1; min-width: 0; }
.ses .n { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; }
.ses .n span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ses .n em { flex: none; font: 500 11px var(--mono); font-style: normal; color: var(--muted); }
.ses .s { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.ses.attention .s { color: #fde68a; }
.ses .ch { color: #6b7488; }
.empty { margin: 40px 0; color: var(--muted); text-align: center; font-size: 13.5px; }

/* 세션 하나 */
.dh { flex: none; display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.dh .w { flex: 1; min-width: 0; }
.dh b { display: block; overflow: hidden; font-size: 15.5px; text-overflow: ellipsis; white-space: nowrap; }
.dh small { color: var(--muted); font-size: 12.5px; }
.dh small.attention { color: #fde68a; }
.dh .ib svg { width: 22px; height: 22px; }
.msg { max-width: 88%; width: fit-content; margin-bottom: 9px; padding: 9px 12px; border-radius: 16px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { margin-left: auto; background: #3b2f78; border-bottom-right-radius: 5px; }
.msg.ai { background: var(--card); border-bottom-left-radius: 5px; color: #dfe3ee; }
.ask { margin: 2px 0 10px; padding: 11px 12px; border: 1px solid rgba(251, 191, 36, 0.35); border-radius: 14px; background: rgba(251, 191, 36, 0.07); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ask b { display: block; margin-bottom: 4px; color: #fde68a; font-size: 12.5px; }
.ask code { display: block; max-height: 240px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.sug { display: block; width: 100%; margin-bottom: 6px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; background: #1b1f2e; color: #e6e9f2; font-size: 13px; text-align: left; }
.sug.on { border-color: var(--violet); background: rgba(139, 92, 246, 0.18); }
.two { display: flex; gap: 8px; margin-bottom: 10px; }
.two .btn { margin: 0; min-height: 42px; font-size: 14px; }
.comp { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.comp textarea { flex: 1; min-height: 42px; max-height: 132px; padding: 9px 13px; }
.comp .go { flex: none; width: 64px; height: 42px; border: 0; border-radius: 13px; background: var(--violet); color: #fff; font-size: 14px; font-weight: 600; }
.comp .go:disabled { opacity: 0.5; }
.comp .stop { flex: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: none; color: var(--bad); }
.note { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
/* 대화(턴): 요청 · 사고과정 · 물어본 것과 고른 답 · 답변 · 근거. 턴 사이는 가는 선으로 나눈다 */
.turn { padding-bottom: 6px; margin-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.turn:last-of-type { border-bottom: 0; }
.msg.me.sending { opacity: 0.6; }
.msg.me.sending small { display: block; margin-top: 3px; color: #c4b8fb; font-size: 11px; }
.msg.ai.streaming { border: 1px solid rgba(139, 92, 246, 0.35); }
.msg.ai.typing { display: flex; gap: 4px; padding: 13px 14px; }
.msg.ai.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.5; }
/* 사고과정: AI가 밝힌 단계(○ 예정 · ▶ 진행 · ✓ 끝 · ✗ 실패). 실행 중이면 펼쳐 둔다 */
.think { margin: 0 0 9px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.think summary { padding: 8px 11px; color: #c9cfdf; font-size: 12.5px; cursor: pointer; list-style: none; }
.think summary::-webkit-details-marker { display: none; }
.think summary::before { content: '▸'; display: inline-block; width: 14px; color: var(--muted); transition: transform 0.15s; }
.think[open] summary::before { transform: rotate(90deg); }
.think ol { margin: 0; padding: 0 11px 9px; list-style: none; }
.think li { display: flex; gap: 8px; padding: 3px 0; font-size: 12.5px; line-height: 1.45; color: #c9cfdf; }
.think li i { flex: none; width: 14px; font-style: normal; text-align: center; color: var(--muted); }
.think li b { color: var(--text); font-weight: 600; }
.think li small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; }
.think li.st-run i { color: var(--run); }
.think li.st-done i { color: var(--ok); }
.think li.st-fail i { color: var(--bad); }
.think li.st-plan { color: var(--muted); }
/* AI가 물어본 것 + 고른 답 */
.qa { margin: 0 0 9px; padding: 9px 11px; border: 1px solid rgba(251, 191, 36, 0.25); border-radius: 12px; background: rgba(251, 191, 36, 0.05); }
.qa b { display: block; color: #fde68a; font-size: 12px; }
.qa p { margin: 3px 0 6px; font-size: 13px; }
.chosen { display: inline-block; padding: 3px 9px; border-radius: 999px; background: rgba(52, 211, 153, 0.13); color: #86efc1; font-size: 12px; }
.chosen.wait { background: rgba(251, 191, 36, 0.1); color: #fcd34d; }
.chosen.mine { display: block; width: fit-content; margin: 0 0 9px auto; }
/* 근거 칩: 👤 지정 · 📖 연 문서 · 🔎 검색 · 🤖 답에 쓴 근거 */
.refs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: -2px 0 9px; }
.refs .rl { color: var(--muted); font-size: 11.5px; margin-right: 2px; }
.ref { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 11.5px; color: #c9cfdf; overflow-wrap: anywhere; }
.ref i { font-style: normal; }
.ref small { color: var(--muted); }
.ref.r-ai { border-color: rgba(139, 92, 246, 0.4); }
/* 지금 하는 일 */
.note.live { display: flex; align-items: center; gap: 8px; color: #c9cfdf; }
.note.live .pulse { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--run); }

/* 아래에서 올라오는 창 · 알림 */
.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.sheet > div { width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; background: var(--panel); }
.sheet h2 { margin: 0 0 6px; font-size: 17px; }
.sheet .hint { margin: 0 0 14px; }
.opt { display: block; width: 100%; min-height: 46px; margin-bottom: 8px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--field); text-align: left; font-size: 14.5px; }
.opt.on { border-color: var(--violet); background: rgba(139, 92, 246, 0.18); }
.opt.danger { color: #fca5a5; }
.seg { display: flex; gap: 8px; margin: 4px 0 14px; }
.seg .opt { margin: 0; text-align: center; }
#toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 20; max-width: 86vw; padding: 10px 14px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 12px; background: #23283a; color: var(--text); font-size: 13.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
@media (prefers-reduced-motion: no-preference) {
  .sheet > div { animation: up 0.18s ease-out; }
  .msg.ai.typing i { animation: dot 1.2s infinite ease-in-out; }
  .msg.ai.typing i:nth-child(2) { animation-delay: 0.15s; }
  .msg.ai.typing i:nth-child(3) { animation-delay: 0.3s; }
  @keyframes dot { 40% { opacity: 1; transform: translateY(-3px); } }
  .note.live .pulse { animation: pulse 1.4s infinite; }
  @keyframes pulse { 50% { opacity: 0.35; } }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } }
}
