/* Remocon 공통 스타일 — R·Q 둘 다 사용
   접근성 원칙:
   - 터치 목표 최소 56px
   - 명암비 충분히 (다크 기본)
   - 포커스 표시 절대 제거하지 않음
   - 애니메이션은 prefers-reduced-motion 존중 */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #949bab;
  --accent: #4d9fff;
  --accent-dim: #1d3a5f;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --danger: #f2545b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button, input, textarea, select { font: inherit; color: inherit; }

button {
  min-height: 56px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #05101f; font-weight: 700; }
button.danger { background: var(--danger); border-color: var(--danger); color: #1a0406; font-weight: 700; }
button.ghost { background: transparent; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

input[type="text"], textarea {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app { display: flex; flex-direction: column; height: 100%; }

/* hidden 은 언제나 이긴다.
   .topbar{display:flex} · .screenwrap img{display:block} 처럼 display 를 정해 둔 곳에서는
   hidden 속성이 무시된다 — 실측 2026-08-10: 도우미 화면에서 위 바와 **깨진 이미지 아이콘**이
   그대로 보였다. */
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.topbar .title { font-weight: 700; font-size: 15px; }
.topbar .spacer { flex: 1; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.on { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--danger); }

.status {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 36px;
  flex: 0 0 auto;
}
.status.busy { color: var(--warn); }
.status.err { color: var(--danger); }

.main { flex: 1 1 auto; overflow: hidden; position: relative; display: flex; flex-direction: column; }

.screenwrap {
  flex: 1 1 auto;
  position: relative;
  background: #05070b;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.screenwrap img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.screenwrap .placeholder { color: var(--muted); font-size: 15px; text-align: center; padding: 24px; }

.touch-effect {
  position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border: 3px solid var(--accent); border-radius: 50%;
  pointer-events: none; animation: ripple 520ms ease-out forwards;
}
@keyframes ripple {
  from { transform: scale(0.3); opacity: 1; }
  to   { transform: scale(1.3); opacity: 0; }
}

.locked::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.35);
  pointer-events: none;
}

/* 항목 목록 — 스크린리더가 읽는 실체 */
/* 항목 목록 — 이전 버전처럼 **본문을 밀지 않는 오버레이**로 올라온다.
   화면 이미지가 늘 대부분을 차지해야 하고, 목록은 필요할 때만 덮는다. */
.items { overflow-y: auto; max-height: 42vh; padding: 8px; background: var(--bg); }
.items.hidden { display: none; }
.items.sheet, .sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 62%;
  background: rgba(12, 15, 22, 0.97);
  border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  z-index: 5;
}

/* ② STT 한 줄 — 높이를 고정해 화면이 흔들리지 않게 한다 (이전 버전과 같은 이유).
   들은 말이 있으면 초록, 없으면 안내 문구. */
.stt {
  flex: 0 0 auto;
  min-height: 46px; display: flex; align-items: center;
  margin: 8px 10px 0; padding: 8px 14px;
  border-radius: 10px;
  background: #37474f; color: #cfd8dc;
  font-size: 15px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stt.heard { background: #2e7d32; color: #fff; font-weight: 700; }
.stt.listening { background: #1e3a5f; color: #90caf9; }

/* ③ 말하기 + 메시지 + 도움요청 */
.cmdbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: var(--panel);
  border-top: 1px solid var(--line);
}
.cmdbar .mic { flex: 0 0 auto; min-width: 116px; }
.cmdbar .help { flex: 0 0 auto; min-width: 104px; }
.cmdmsg {
  flex: 1 1 auto; min-width: 0;
  color: var(--muted); font-size: 14px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmdmsg.busy { color: var(--warn); }
.cmdmsg.err { color: var(--danger); }
.item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; margin: 6px 0;
  background: var(--panel2);
}
.item .idx {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px;
  background: var(--panel); color: var(--muted);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.item .txt { flex: 1 1 auto; }
.item[aria-disabled="true"] { opacity: 0.5; }

.controls {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px; background: var(--panel); border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.controls button { min-height: 60px; font-size: 15px; }

.micbar { display: flex; gap: 8px; padding: 10px; background: var(--panel); flex: 0 0 auto; }
.micbar .mic { flex: 2 1 auto; font-size: 18px; font-weight: 700; min-height: 68px; }
.micbar .mic.on { background: var(--ok); border-color: var(--ok); color: #052014; }
.micbar .help { flex: 1 1 auto; }
.micbar .help.active { background: var(--warn); border-color: var(--warn); color: #201400; }

/* 다이얼로그 */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: grid; place-items: center; z-index: 900; padding: 16px;
}
.backdrop[hidden] { display: none; }
.dialog {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  width: 100%; max-width: 460px; max-height: 86vh; overflow: auto; padding: 18px;
}
.dialog h2 { margin: 0 0 6px; font-size: 18px; }
.dialog .sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.dialog .row { display: flex; gap: 8px; margin-top: 12px; }
.dialog .row button { flex: 1; }

.metrics {
  position: absolute; right: 8px; bottom: 8px; z-index: 50;
  background: rgba(10,12,16,0.85); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; color: var(--muted);
  font-family: ui-monospace, Consolas, monospace; line-height: 1.5;
  pointer-events: none;
}
.metrics[hidden] { display: none; }
.metrics b { color: var(--text); font-weight: 600; }

.log {
  max-height: 22vh; overflow-y: auto; padding: 8px 12px;
  font-size: 13px; font-family: ui-monospace, Consolas, monospace;
  background: #0b0d12; border-top: 1px solid var(--line); color: var(--muted);
}
.log div { padding: 2px 0; }
.log .me { color: var(--accent); }
.log .err { color: var(--danger); }
.log .ok { color: var(--ok); }

.banner {
  padding: 12px 14px; margin: 8px; border-radius: 12px;
  background: var(--panel2); border: 1px solid var(--line);
}
.banner.warn { border-color: var(--warn); }
.banner.danger { border-color: var(--danger); }
.banner[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 420px) {
  .controls { grid-template-columns: repeat(2, 1fr); }
}
/* ==================== 처리 중 표시 ====================
   이식 원본: KioskTwinScreen.ProcessingOverlay(statusMessage)
   화면을 못 보는 사용자에게는 app.js 가 2초 뒤 소리로도 알린다. */
.processing {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(20, 22, 28, .92);
  color: #fff;
  font-size: 16px;
  z-index: 60;
  pointer-events: none;
}
.processing[hidden] { display: none; }
.processing .spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .processing .spinner { animation: none; }
}

/* 다이얼로그를 손으로 밀어 옮긴다 (movePlanDialog / moveCandidateDialog) */
.dialog-head {
  cursor: grab;
  touch-action: none;
}
.dialog-head:active { cursor: grabbing; }


/* ==================== 폰에서 앱처럼 (이전 버전 KioskTwinScreen 과 같은 3단) ====================
   ① 화면 이미지가 남는 공간을 전부 차지한다  ② STT 한 줄  ③ 말하기 + 메시지
   아래 이동 버튼은 **한 줄**로 눌러 담는다 — 두 줄을 쓰면 이미지가 그만큼 작아진다. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.controls { display: flex; gap: 8px; padding: 8px 10px 10px; }
.controls button { flex: 1 1 0; min-height: 48px; font-size: 15px; }

.stt { font-size: 16px; min-height: 44px; }
.cmdbar { padding: 8px 10px; gap: 8px; }
.cmdbar .mic { min-width: 98px; min-height: 52px; font-size: 17px; }
.cmdbar .help { min-width: 92px; min-height: 52px; font-size: 15px; }
.cmdmsg { font-size: 13px; }

.topbar .title { font-size: 15px; }
.log { max-height: 22vh; }

/* 위쪽 작은 이동 버튼 — 이미지 자리를 뺏지 않는다 */
.topbar .icon {
  min-width: 40px; min-height: 40px; padding: 0 8px;
  font-size: 17px; line-height: 1;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--fg);
}
.topbar .icon[aria-pressed="true"] { background: var(--accent); color: #04121a; }
.topbar { gap: 6px; padding: 6px 8px; }

/* 상태 줄은 **화면에서 감춘다** — 같은 말이 아래 명령 바에 보이고, 위 제목과도 겹친다.
   스크린리더는 그대로 읽는다(sr-only). */
.status.sr-only {
  padding: 0; min-height: 0; border: 0; background: none;
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* 키오스크 화면 — 폭에 맞춰 최대한 크게, **잘라내지 않는다**.
   (꽉 채우려면 가장자리를 잘라야 하고, 잘린 버튼은 누를 수도 읽을 수도 없다.)

   비율이 달라 남는 세로 공간은 **아래 두 줄이 나눠 갖는다**. 검은 띠로 비워 두면
   화면이 작아 보이고, 그 자리에 아무 쓸모가 없다. */
.main { flex: 1 1 auto; }
.screenwrap { background: var(--bg); }
/* 아래쪽에 붙인다 — 남는 자리를 위(연결 점이 있는 쪽)로 몰아 두면 구멍처럼 보이지 않는다 */
.screenwrap img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }

/* STT 한 줄은 잘리지 않게 두 줄까지 */
.stt {
  font-size: 15px; line-height: 1.35;
  white-space: normal; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}


/* ==================== 아래 두 줄 (말하기 / 도움요청) ====================
   각 줄은 [토글 버튼] + [글자] 다.
   버튼은 폭을 좁게·높이를 넉넉히 잡고 글자를 두 줄로 넣는다 — 엄지로 누르기 좋고
   옆의 글자 영역이 넓어진다. 글자는 작게: 화면 이미지가 주인공이다.
   `.bar` 로 한정한다. `.row` 는 대화상자 안에서도 쓰기 때문이다. */
.row.bar {
  flex: 1 1 auto; max-height: 132px;
  display: flex; align-items: stretch; gap: 8px;
  padding: 8px 10px; background: var(--panel);
  border-top: 1px solid var(--line);
}
.row.bar > button {
  flex: 0 0 auto; width: 76px; min-width: 76px; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 6px 2px;
  font-size: 15px; font-weight: 700; line-height: 1.2; letter-spacing: -0.3px;
  border: 0; border-radius: 16px; color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.row.bar > button span { display: block; }

/* 곁들이 버튼 (소리 켜기/끄기) — 주인공인 두 토글보다 작게 */
.row.bar > button.small {
  width: 50px; min-width: 50px; min-height: 44px; align-self: center;
  font-size: 20px; border-radius: 14px;
  background: var(--panel2); color: var(--fg); box-shadow: none;
}
.row.bar > button.small[aria-pressed="true"] {
  background: var(--panel2); color: var(--muted); box-shadow: none;
  opacity: 0.75;
}

/* 두 버튼은 색으로 구분한다 — 말하기는 파랑, 도움은 주황.
   켜지면 밝은 초록으로 바뀌어 "지금 켜져 있다"가 한눈에 보인다. */
.row.bar > button.mic  { background: linear-gradient(#3d7bfd, #2a5fd8); }
.row.bar > button.help { background: linear-gradient(#f5a524, #d98613); color: #2a1a00; }
.row.bar > button[aria-pressed="true"], .row.bar > button.on {
  background: linear-gradient(#22c55e, #16a34a); color: #04210f;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}
.row.bar > button:active { transform: translateY(1px); }

/* 글자 영역 — 줄 전체를 쓰고 배경은 두지 않는다. 글자만 보이는 편이 읽기 쉽다. */
.row.bar .line {
  flex: 1 1 auto; width: 100%; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  -webkit-box-pack: center;   /* 두 줄 자리를 잡아 두고 글자는 가운데에 */
  padding: 4px 8px; background: none; border-radius: 0;
  color: #aab6c0; font-size: 12px; line-height: 1.4;
  overflow: hidden;
}
.row.bar .line.heard { color: #7ee2a8; font-weight: 600; }      /* 들은 말 */
.row.bar .line.listening { color: #90caf9; }                    /* 듣는 중 */

/* 화면 위에 얹는 표시 (연결 점 · 목록) */
.hud {
  position: absolute; top: 6px; left: 6px; right: 6px;
  display: flex; align-items: center; gap: 6px; z-index: 4;
  pointer-events: none;
}
.hud .icon {
  pointer-events: auto;
  min-width: 32px; min-height: 32px; padding: 0 4px;
  font-size: 14px; border-radius: 9px; opacity: 0.75;
  background: rgba(20, 24, 32, 0.55); border: 1px solid var(--line); color: var(--fg);
}
.hud .spacer { flex: 1 1 auto; }
