/* Troubadour web UI - things that sit above the page: the sandbox
   pane, the activity panel, toasts, modals, menus, the lightbox and the
   connection banner. */

/* ---------------- Sandbox pane ---------------- */

.pane { flex: 0 0 var(--pane-w); width: var(--pane-w); border-left: 1px solid var(--border);
  background: var(--surface); display: none; flex-direction: column; min-height: 0; }
.pane.open { display: flex; }
.pane__head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s3) 0 var(--s4);
  height: var(--header-h); border-bottom: 1px solid var(--border); }
.pane__head h3 { font-size: var(--fs-md); margin: 0; }
.pane__close { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: var(--radius-xs); }
.pane__close:hover { color: var(--text); background: var(--surface-2); }
.pane__body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pane__frame { flex: 1 1 auto; width: 100%; border: none; background: #0b0d10; min-height: 300px; }
@media (max-height: 520px) {
  .pane__body { overflow-y: auto; }
  .pane__frame { flex: 1 1 100px; min-height: 96px; }
  .pane__status { padding: 5px 10px; }
  .pane__sessions { padding: 5px 10px; gap: 2px; }
  .pane__controls { padding: 6px 10px; gap: 6px; }
}
.pane__hint { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: var(--fs-md); padding: var(--s6); }
.pane__status { padding: var(--s2) var(--s4); font-size: var(--fs-sm); color: var(--muted);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--s2); }
.pane__retry { margin-left: auto; }
.pane__chip[data-state="failed"] { color: var(--danger); }
/* gh #59: taken control is a live state; filled, warn-toned like the header chip */
.pane__takeover.is-on, .pane__takeover.is-on:not(:disabled):hover {
  background: var(--warn); border-color: var(--warn); color: #fff; }
.pane__controls { padding: var(--s3) var(--s4); display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------------- Activity panel ---------------- */

.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 40; }
.panel { position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 94vw; background: var(--bg);
  border-left: 1px solid var(--border); z-index: 41; display: flex; flex-direction: column; box-shadow: var(--shadow-3); }
.panel__head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s4);
  height: var(--header-h); border-bottom: 1px solid var(--border); }
.panel__head h3 { font-size: var(--fs-base); margin: 0; }
.panel__body { flex: 1 1 auto; overflow-y: auto; padding: var(--s2) var(--s2) var(--s5); }
.panel__group-title { padding: var(--s3) var(--s3) 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; }
.panel__event { padding: 7px var(--s3); display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius-xs); }
.panel__event:hover { background: var(--surface); }
.panel__muted { color: var(--muted); font-style: italic; }
.panel__time { font-size: var(--fs-xs); color: var(--muted-2); white-space: nowrap; min-width: 52px; }
.panel__text { font-size: var(--fs-sm); }
.panel__text code { color: var(--primary); }

/* ---------------- Shell banners, toasts, and connection status ---------------- */

.shell-banners {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: stretch;
  gap: 6px; padding: 0 var(--s4); z-index: 15;
}
.shell-banners:has(> :not([hidden])) { padding-top: 6px; padding-bottom: 6px; }

.toasts { position: fixed; bottom: var(--s5); right: var(--s4); left: auto; transform: none; display: flex;
  flex-direction: column; gap: var(--s2); z-index: 60; max-width: min(92vw, 420px); align-items: flex-end;
  pointer-events: none; }
body.has-composer .toasts { bottom: 108px; }
.toast { display: flex; align-items: center; gap: var(--s3); max-width: 100%; cursor: pointer;
  pointer-events: auto;
  background: var(--text); color: var(--bg); padding: 10px var(--s4); border-radius: var(--radius-sm);
  font-size: var(--fs-md); box-shadow: var(--shadow-2); animation: toast-in 0.18s ease-out; }
.toast--error { background: var(--card); color: var(--text); border: 1px solid var(--danger);
  border-left-width: 4px; }
.toast--error::before { content: "!"; flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; font-weight: 800; font-size: 13px; display: inline-flex;
  align-items: center; justify-content: center; }
.toast__action { border: none; background: transparent; color: #8fb0ff; font-weight: 700; cursor: pointer;
  padding: 0 0 0 var(--s2); font-size: var(--fs-md); }
html.dark .toast__action { color: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.conn { align-self: center; max-width: 100%;
  padding: 5px var(--s4); border-radius: var(--pill); font-size: var(--fs-sm); font-weight: 550;
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  backdrop-filter: blur(6px); box-shadow: var(--shadow-1); text-align: center; }
.conn[hidden] { display: none; }
.conn--floating { position: fixed; top: var(--s3); left: 50%; transform: translateX(-50%); z-index: 90;
  max-width: min(92vw, 520px); }

/* ---------------- Menus and modals ---------------- */

.goal-row { position: relative; }
.menu { position: absolute; right: 6px; top: calc(100% - 6px); z-index: 25; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-2); padding: 4px;
  display: flex; flex-direction: column; min-width: 180px; }
.menu button { border: none; background: transparent; color: var(--text); text-align: left; padding: 9px 12px;
  border-radius: var(--radius-xs); cursor: pointer; font-size: var(--fs-md); }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }

.modal__card { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 42;
  width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px; padding: var(--s5); display: flex; flex-direction: column;
  gap: var(--s3); box-shadow: var(--shadow-3); }
.modal__card h3 { font-size: var(--fs-lg); margin: 0; }
.modal__row { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s1); }
.modal__card .field { margin-bottom: 0; }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.78); display: flex;
  align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: var(--radius-sm); }
.lightbox a.b__attach__dlbtn { position: absolute; top: 12px; right: 16px; width: 34px; height: 34px;
  background: var(--card); color: var(--text); }

/* ---------------- The Android app, offered (web/android.js) ---------------- */

.app-offer { display: flex; align-items: center; gap: var(--s2); width: 100%; max-width: 680px;
  align-self: center;
  padding: var(--s2) var(--s2) var(--s2) var(--s3); border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-1); }
.app-offer--floating { position: fixed; left: var(--s3); right: var(--s3); z-index: 30;
  top: var(--s3); box-shadow: var(--shadow-2); }
.app-offer__text { flex: 1; font-size: var(--fs-sm); line-height: 1.35; }
.app-offer__close { background: none; border: 0; color: var(--muted); font-size: 16px;
  min-width: 32px; min-height: 32px; cursor: pointer; }
.app-offer a.btn, .android-app a.btn { text-decoration: none; }
@media (min-width: 768px) {
  .app-offer--floating { left: auto; right: var(--s4); max-width: 420px; }
}
.android-app p { margin: 0 0 var(--s2); }
.android-app__cmd { display: block; margin-top: var(--s1); padding: var(--s2);
  border-radius: var(--radius-xs); background: var(--surface-2);
  font-size: var(--fs-sm); overflow-wrap: anywhere; }
