/* TERMINAL: 舞台・字幕・入力を可視領域内に固定する。 */
:root{
  --iris-vh:100vh;
  --iris-vtop:0px;
}
body.terminal-session{
  --iris-dock:calc(60px + env(safe-area-inset-bottom,0px));
}
body.terminal-session > header{display:none}
body.terminal-session #terminal{
  position:fixed;
  top:var(--iris-vtop);
  bottom:auto;
  height:calc(var(--iris-vh) - var(--iris-dock));
  padding:0;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
}
body.terminal-session > nav{
  top:calc(var(--iris-vtop) + var(--iris-vh) - var(--iris-dock));
  bottom:auto;
  height:var(--iris-dock);
}
body.terminal-keyboard{--iris-dock:0px}
body.terminal-keyboard > nav{display:none}

#tchat{
  height:100%;
  min-height:0;
  display:flex;
  flex-direction:column;
}
#tchat > *{flex-shrink:0}
#tchat #thead{
  position:relative;
  top:auto;
  margin:0;
  min-height:52px;
  padding:calc(5px + env(safe-area-inset-top,0px)) 12px 5px 4px;
  gap:6px;
}
#tchat #tback{min-width:44px;min-height:44px}
#tchat #thead .nm b,
#tchat #thead .nm small{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#tchat #thead #voiceBtn{
  position:static;
  flex:none;
  min-height:44px;
  padding:7px 8px;
  letter-spacing:.06em;
  white-space:nowrap;
}
@media(max-width:380px){
  #tchat #thead > img{display:none}
}
#logBtn,#logClose{
  min-width:44px;
  min-height:44px;
  padding:8px 12px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--bg2);
  color:var(--ink);
  font:inherit;
  font-size:12px;
  cursor:pointer;
}
#tchat #stagebox{
  position:relative;
  top:auto;
  flex:1 1 0;
  height:auto;
  min-height:0;
  margin:0;
}
#stagebox.broadcast{display:none}
#tchat #voiceBtn{z-index:2}
#subtitle{
  flex:0 1 112px;
  height:112px;
  min-height:76px;
  margin-top:auto;
  padding:10px 18px;
  overflow:auto;
  border-top:1px solid var(--line);
  background:linear-gradient(180deg,var(--bg2),var(--bg));
}
#subtitleWho{
  display:block;
  margin:0 0 6px;
  color:var(--cy);
  font:600 10px/1.5 ui-monospace,monospace;
  letter-spacing:.08em;
}
#subtitleText{
  margin:0;
  color:var(--ink);
  font-size:18px;
  line-height:1.75;
  overflow-wrap:anywhere;
  white-space:pre-wrap;
  opacity:1;
  transition:opacity .18s ease;
}
#subtitleText.fading{opacity:0}
#subtitle.error{border-top-color:var(--mg)}
#subtitle.error #subtitleWho{color:var(--mg)}
#subtitle.error #subtitleWho::before{content:"⚠ "}
#subtitle #stagecap{
  position:static;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:none;
  backdrop-filter:none;
  color:var(--dim);
  font-size:12px;
  line-height:1.8;
}
#subtitle #stagecap:empty{display:none}
#subtitle #stagecap.pre{color:var(--cy)}
#stagebox.wav + #subtitle #subtitleWho,
#stagebox.wav + #subtitle #stagecap.pre{color:var(--mg)}
#tchat #chips{
  min-height:44px;
  padding:4px 14px;
  align-items:center;
}
#tchat #chips button{min-height:36px}
#tchat #seed{
  width:calc(100% - 28px);
  min-height:44px;
  margin:0 14px;
  padding:10px;
}
#tchat #f{
  position:relative;
  bottom:auto;
  min-height:56px;
  padding:6px 14px;
  background:var(--bg);
}
#tchat #q{min-height:44px;font-size:16px}
#tchat .send{width:44px;height:44px}
#log .revise input{font-size:16px}
#log .seedcard .acts button{
  flex:1 1 calc(50% - 8px);
  min-width:0;
  margin:0;
  width:auto;
  line-height:1.5;
  overflow-wrap:anywhere;
}
#log .read-rest{
  display:block;
  min-height:44px;
  margin-top:8px;
  padding:8px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:var(--bg2);
  color:var(--cy);
  font:inherit;
  font-size:12px;
  cursor:pointer;
}

#broadcastFeed{
  flex:1 1 0;
  min-height:0;
  display:flex;
  flex-direction:column;
}
#logDialog{
  position:fixed;
  top:calc(var(--iris-vtop) + 12px);
  bottom:auto;
  width:min(620px,calc(100% - 24px));
  height:calc(var(--iris-vh) - 24px);
  max-height:calc(var(--iris-vh) - 24px);
  max-width:none;
  margin:0 auto;
  padding:0;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--bg);
  color:var(--ink);
}
#logDialog[open]{display:flex;flex-direction:column}
#logDialog::backdrop{
  background:rgba(0,0,0,.65);
  backdrop-filter:blur(3px);
}
.log-head{
  flex:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 14px;
  border-bottom:1px solid var(--line);
}
#logTitle{
  font:600 12px/1.5 ui-monospace,monospace;
  letter-spacing:.12em;
}
#tchat #log{
  flex:1 1 0;
  min-height:0;
  padding:16px;
  overflow:auto;
  overscroll-behavior:contain;
  scroll-behavior:auto;
}
#log .row,#log .row.me{
  flex-direction:row;
  align-items:flex-start;
  gap:10px;
  padding:0 0 14px;
  margin:0 0 14px;
  border-bottom:1px solid var(--line);
}
#log .row .ic{display:none}
#log .row .col{flex:1;max-width:none}
#log .row .bb2{
  padding:0;
  border-radius:0;
  background:none;
  color:var(--ink);
  font-size:14px;
  font-weight:400;
}
#log .row.me .col::before{
  content:"あなた";
  display:block;
  margin-bottom:4px;
  color:var(--dim);
  font-size:10.5px;
}
#log .row .who{margin-left:0}
#log .row .tm{align-self:flex-start;padding-top:2px}
#log .row[data-unplayed="true"] .col::after{
  content:"音声・字幕の進行を中断しました";
  display:block;
  margin-top:6px;
  color:var(--dim);
  font-size:11px;
}
#log .row .bb2.glitch{color:var(--ink)}
body.terminal-keyboard #tchat #thead{
  min-height:48px;
  padding-top:calc(2px + env(safe-area-inset-top,0px));
  padding-bottom:2px;
}
body.terminal-keyboard #thead img{width:30px;height:30px}
body.terminal-keyboard #thead .nm small{display:none}
body.terminal-keyboard #subtitle{
  flex-basis:86px;
  height:86px;
  min-height:64px;
  padding:6px 14px;
}
body.terminal-keyboard #subtitleText{font-size:16px;line-height:1.6}
body.terminal-keyboard #tchat #seed,
body.terminal-keyboard #tchat #chips{display:none}
@media(prefers-reduced-motion:reduce){
  #subtitleText,#subtitle #stagecap{transition:none}
  #log .glitch,#glitch.on,#thead img.shake{animation:none}
}
