/* Standard layout remains available outside immersive mode. */
#assist { position: relative; }
.session-bar { padding-right: 128px; }
#finish { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; z-index: 8; font-size: 14px; }
.tools-launcher, .immersive-takeover { display: none; }
.install-guide { max-width: 700px; margin: 0 auto 24px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--soft); }
.install-guide p { margin: 10px 0 0; font-size: 15px; }
.install-guide button { float: right; font-size: 13px; padding: 5px 10px; min-height: 36px; margin-left: 8px; }

html.assist-immersive, html.assist-immersive body { overflow: hidden; overscroll-behavior: none; background: #080c0a; }
html.assist-immersive #install-guide { display: none; }
#assist.immersive {
  position: fixed; top: var(--visible-top, 0px); left: var(--visible-left, 0px);
  width: 100vw; width: var(--visible-width, 100vw);
  height: 100vh; height: 100dvh; height: var(--visible-height, 100dvh);
  max-width: none; max-height: none; margin: 0; padding: 0; z-index: 100;
  background: #080c0a; overflow: hidden; isolation: isolate;
}
#assist.immersive .session-bar,
#assist.immersive .connection,
#assist.immersive #operation-status { display: none; }
#assist.immersive .screen-area {
  position: absolute; top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px);
  width: auto; height: auto; max-width: none; max-height: none; min-height: 0; min-width: 0;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: #080c0a;
}
/* Canvas dimensions are exclusively calculated by FamilyPhoneView's contain fit.
   Never stretch/crop it using width:100%, object-fit:cover or CSS scale. */
#assist.immersive canvas { max-width: none; max-height: none; box-shadow: none; }
#assist.immersive .toolbar {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
  transform: translateX(-50%); z-index: 5; margin: 0; padding: 6px; border: 1px solid #ffffff30;
  width: max-content; max-width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 16px);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; border-radius: 18px;
  background: #14271ed9; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px #0005; transition: opacity .18s ease, visibility .18s ease;
}
#assist.immersive .toolbar button { flex: 0 0 auto; max-width: none; min-width: 44px; min-height: 44px; font-size: 14px; padding: 7px 9px; border-radius: 12px; color: #fff; background: #ffffff18; }
#assist.immersive.tools-hidden .toolbar { opacity: 0; visibility: hidden; pointer-events: none; }
#assist.immersive .tools-launcher {
  display: inline-flex; position: absolute; z-index: 7;
  right: calc(env(safe-area-inset-right, 0px) + 12px); bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  min-width: 48px; min-height: 44px; padding: 6px 10px; border: 1px solid #ffffff50;
  background: #14271ebf; color: #fff; font-size: 14px; border-radius: 14px;
}
#assist.immersive #finish {
  z-index: 12;
  top: calc(env(safe-area-inset-top, 0px) + 8px); right: calc(env(safe-area-inset-right, 0px) + 10px);
  min-height: 44px; padding: 7px 11px; background: #a72e2edb; color: #fff; font-size: 13px;
  border: 1px solid #ffffff40; border-radius: 13px;
}
#assist.immersive .immersive-takeover {
  position: absolute; z-index: 7; display: inline-flex; top: 50%; left: 50%; transform: translate(-50%, 60px);
  padding: 10px 16px; background: #1b6b55; color: #fff;
}
#assist.immersive #composer {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
  left: calc(env(safe-area-inset-left, 0px) + 8px); right: calc(env(safe-area-inset-right, 0px) + 8px);
  z-index: 9; width: auto; max-width: 900px; margin: auto; max-height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 124px);
  overflow: auto; overscroll-behavior: contain; padding: 12px; border: 1px solid #b7cbbf; border-radius: 18px;
  background: #f8fcf9f5; box-shadow: 0 8px 30px #0005;
}
#assist.immersive #composer textarea { font-size: 16px; }
#assist.immersive:has(#composer:not([hidden])) .toolbar { visibility: hidden; pointer-events: none; }
#assist.immersive.awaiting-takeover #empty { transform: translateY(-45px); }
@media (max-width: 360px) { #assist.immersive .toolbar button { padding: 6px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { #assist.immersive .toolbar { transition: none; } }
