/* ==========================================================================
   subbox.css — 마이크 자막 박스 (2026-12-01 대표 지시)
   --------------------------------------------------------------------------
   · 두 줄 자막: 방금 한 말 / 직전 말
   · 끌어서 옮기기, 접기, 크기 3단, 전체화면, 닫기·다시 열기
   · 자리·크기·접힘 상태는 이 기기에 저장한다
   · 전체화면에서도 목차(☰)를 열 수 있다 — 일부러 목차(130)보다 낮은 층에 둔다
   ========================================================================== */

/* 예전 인식 자막은 새 자막 박스가 대신한다 */
.u40-caption{display:none !important;}

.subbox{
  --sb-fs:16px;
  --sb-lh:1.45;
  position:fixed; z-index:60; left:8px; bottom:calc(148px + env(safe-area-inset-bottom));
  width:min(72vw,400px); max-width:calc(100vw - 118px);
  background:rgba(12,15,20,.94);
  color:#F2F6FA;
  border:1px solid rgba(150,255,200,.28);
  border-radius:16px;
  box-shadow:0 18px 44px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.2) inset;
  backdrop-filter:blur(12px) saturate(1.1);
  -webkit-backdrop-filter:blur(12px) saturate(1.1);
  overflow:hidden;
  font-size:var(--sb-fs); line-height:var(--sb-lh);
  transition:opacity .18s ease, transform .18s ease;
  contain:layout paint;
}
.subbox[data-hidden="1"]{display:none;}
.subbox[data-size="sm"]{--sb-fs:14px;}
.subbox[data-size="md"]{--sb-fs:16px;}
.subbox[data-size="lg"]{--sb-fs:19px;}
.subbox[data-collapsed="1"] .sb-body,
.subbox[data-collapsed="1"] .sb-foot{display:none;}
.subbox[data-collapsed="1"]{border-radius:999px;}

/* 끌어서 옮길 때 */
.subbox[data-drag="1"]{transition:none; box-shadow:0 26px 60px rgba(0,0,0,.55);}
.subbox[data-drag="1"] .sb-head{cursor:grabbing;}

.sb-head{
  display:flex; align-items:center; gap:8px;
  padding:8px 10px 6px; cursor:grab;
  touch-action:none; user-select:none; -webkit-user-select:none;
  border-bottom:1px solid rgba(255,255,255,.06);
  background:linear-gradient(180deg,rgba(255,255,255,.06),rgba(255,255,255,0));
}
.subbox[data-collapsed="1"] .sb-head{border-bottom:0;}
.sb-dot{width:8px;height:8px;border-radius:50%;background:#4BD84B;box-shadow:0 0 10px #4BD84B;flex:0 0 auto;}
.subbox[data-state="thinking"] .sb-dot{background:#B79BE8;box-shadow:0 0 10px #B79BE8;}
.subbox[data-state="speaking"] .sb-dot{background:#C9B3F2;box-shadow:0 0 10px #C9B3F2;}
.sb-title{font-size:12px;font-weight:800;letter-spacing:-.01em;color:#CFE9DA;}
.sb-state{font-size:11.5px;font-weight:700;color:#9FC7B2;margin-right:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.sb-tools{display:flex;align-items:center;gap:2px;}
.sb-tools button{
  appearance:none;border:0;background:transparent;color:#C9D6E2;
  width:30px;height:30px;border-radius:9px;display:grid;place-items:center;
  font-size:12px;font-weight:800;line-height:1;
}
.sb-tools button:hover,.sb-tools button:focus-visible{background:rgba(255,255,255,.1);color:#fff;outline:none;}
.sb-tools button[aria-pressed="true"]{background:rgba(201,179,242,.22);color:#EADFFF;}

.sb-body{padding:10px 14px 12px;}
.sb-line{margin:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word;}
.sb-now{font-weight:700;color:#FFFFFF;}
.sb-prev{margin-top:4px;font-size:.86em;color:#9DB0C2;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden;}
.sb-who{
  display:inline-block;margin-right:6px;font-size:.72em;font-weight:800;letter-spacing:.02em;
  color:#7FE8B4;border:1px solid rgba(127,232,180,.35);border-radius:999px;padding:0 6px;
  vertical-align:1px;
}
.sb-who[data-who="me"]{color:#CFC0F5;border-color:rgba(201,179,242,.4);}
.sb-empty{color:#8296A8;font-size:.94em;}

.sb-foot{
  display:flex;align-items:center;gap:6px;flex-wrap:wrap;
  padding:0 10px 10px;
}
.sb-foot button{
  appearance:none;border:1px solid rgba(255,255,255,.14);background:rgba(255,255,255,.06);
  color:#DCE6F0;border-radius:999px;height:30px;padding:0 11px;font-size:12px;font-weight:700;
}
.sb-foot button:hover{background:rgba(255,255,255,.12);}
.sb-foot .sb-hint{margin-left:auto;font-size:11px;color:#7E93A6;}

/* 전체화면 — 화면을 크게 쓰되 목차(130)·시트(200)보다 아래 */
.subbox[data-full="1"]{
  z-index:68; left:8px; right:8px; bottom:calc(96px + env(safe-area-inset-bottom));
  width:auto; max-width:none; transform:none;
  top:calc(58px + env(safe-area-inset-top)); bottom:calc(96px + env(safe-area-inset-bottom));
  display:flex; flex-direction:column;
}
.subbox[data-full="1"] .sb-body{
  flex:1 1 auto; overflow:auto; display:flex; flex-direction:column; justify-content:flex-end;
  padding:18px 20px;
}
.subbox[data-full="1"] .sb-line{-webkit-line-clamp:4;font-size:1.34em;line-height:1.5;}
.subbox[data-full="1"] .sb-prev{-webkit-line-clamp:3;font-size:1.05em;}
.subbox[data-full="1"] .sb-foot{justify-content:space-between;}

/* 자막이 떠 있는 동안은 대화 본문 아래를 넉넉히 비워 마지막 말이 가리지 않게 한다 */
@media (max-width:899px){
  body.subbox-on #s-chat .chatlog{padding-bottom:320px !important;}
  body.subbox-full #s-chat .chatlog{padding-bottom:96px !important;}
}
/* 전체화면일 때는 떠 있는 마이크 대신 자막 안의 마이크를 쓴다(겹침 0) */
body.subbox-full .fabwrap{visibility:hidden !important; pointer-events:none !important;}
.sb-mic{
  appearance:none;border:1px solid rgba(155,246,200,.45);background:rgba(75,216,75,.16);
  color:#D9FFE6;border-radius:999px;height:34px;padding:0 14px;font-size:13px;font-weight:800;
  display:none;align-items:center;gap:6px;
}
body.subbox-full .sb-mic{display:inline-flex;}
.sb-mic:active{transform:scale(.97);}

/* 라이트 화면 */
html:not([data-theme="dark"]) .subbox{
  background:rgba(255,255,255,.96); color:#15212E; border-color:rgba(18,120,80,.22);
  box-shadow:0 18px 40px rgba(20,40,30,.18);
}
html:not([data-theme="dark"]) .sb-now{color:#0E1A26;}
html:not([data-theme="dark"]) .sb-prev{color:#5A6B7C;}
html:not([data-theme="dark"]) .sb-head{background:linear-gradient(180deg,rgba(0,0,0,.04),transparent);border-bottom-color:rgba(0,0,0,.06);}
html:not([data-theme="dark"]) .sb-title{color:#1E6B4A;}
html:not([data-theme="dark"]) .sb-state{color:#3F6B57;}
html:not([data-theme="dark"]) .sb-tools button{color:#405266;}
html:not([data-theme="dark"]) .sb-tools button:hover{background:rgba(0,0,0,.06);color:#0E1A26;}
html:not([data-theme="dark"]) .sb-foot button{color:#21384A;background:rgba(0,0,0,.04);border-color:rgba(0,0,0,.1);}

/* 닫아 둔 자막을 다시 여는 손잡이 */
.subtab{
  position:fixed; right:10px; bottom:calc(214px + env(safe-area-inset-bottom)); z-index:61;
  display:none; align-items:center; gap:6px;
  height:34px; padding:0 12px 0 10px; border-radius:999px;
  background:rgba(12,15,20,.92); color:#DDF3E6; border:1px solid rgba(150,255,200,.3);
  font-size:12px; font-weight:800; box-shadow:0 12px 28px rgba(0,0,0,.36);
}
.subtab[data-on="1"]{display:inline-flex;}
.subtab b{width:7px;height:7px;border-radius:50%;background:#4BD84B;box-shadow:0 0 8px #4BD84B;}
.subtab:active{transform:scale(.97);}

@media (prefers-reduced-motion: reduce){
  .subbox{transition:none;}
}
