/* Sandbox browser viewer (src/apps/browser.ts). */

.brw {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-2);
  --brw-tone: var(--dim);
  --brw-tone-bg: var(--panel);
}
.brw[data-controller="ai"] {
  --brw-tone: var(--blue);
  --brw-tone-bg: #0e1a2b;
}
.brw[data-controller="user"] {
  --brw-tone: var(--acc);
  --brw-tone-bg: #0c1f13;
}
.brw[data-controller="paused"] {
  --brw-tone: var(--amber);
  --brw-tone-bg: var(--amber-dim);
}

/* ---- who's driving ---- */
.brw-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--brw-tone);
  background: var(--brw-tone-bg);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.brw-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brw-tone);
}
.brw[data-controller="ai"] .brw-dot {
  animation: brw-pulse 1.6s ease-in-out infinite;
}
@keyframes brw-pulse {
  50% {
    box-shadow: 0 0 0 5px transparent;
    opacity: 0.55;
  }
}
.brw-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.brw-who {
  color: var(--brw-tone);
  font-size: 13px;
}
.brw-sub {
  color: var(--text-2);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- address bar ---- */
.brw-nav .brw-url {
  flex: 1;
  min-width: 80px;
  height: 26px;
  font-size: 12px;
}
.brw-nav .brw-url[readonly] {
  color: var(--text-2);
  background: var(--bg-2);
  cursor: default;
}
.brw-fwd .ico {
  transform: scaleX(-1);
}
.brw-shield {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  color: var(--acc-2);
  font-size: 11px;
  white-space: nowrap;
}

/* ---- tabs ---- */
.brw-tabs {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 4px 6px 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
}
.brw-tabs[hidden] {
  display: none;
}
.brw-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  height: 26px;
  padding: 0 4px 0 10px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--r) var(--r) 0 0;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}
.brw-tab:hover {
  background: var(--panel-2);
}
.brw-tab.is-active {
  background: var(--bg-2);
  border-color: var(--line-2);
  color: var(--text);
}
.brw-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brw-tab-x {
  width: 18px;
  height: 18px;
}

/* ---- the page ---- */
.brw-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #050607;
}
.brw-screen {
  display: block;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 1px var(--line);
}
.brw-screen:focus-visible {
  box-shadow: 0 0 0 2px var(--brw-tone);
}
.brw-screen.is-locked {
  cursor: not-allowed;
}

.brw-notices {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(520px, 70%);
  pointer-events: none;
}
.brw-notice {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-left-width: 3px;
  border-radius: var(--r);
  background: rgba(10, 13, 14, 0.94);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  animation: brw-in 0.18s var(--ease);
}
.brw-notice.is-info {
  border-left-color: var(--blue);
}
.brw-notice.is-guard {
  border-left-color: var(--acc);
}
.brw-notice.is-warn {
  border-left-color: var(--amber);
}
@keyframes brw-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.brw-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 7, 0.82);
}
.brw-overlay[hidden] {
  display: none;
}
.brw-overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 440px;
  padding: 20px;
  color: var(--text-2);
  text-align: center;
}
.brw-overlay-box p {
  margin: 0;
}
.brw-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-3);
  border-top-color: var(--brw-tone, var(--acc));
  border-radius: 50%;
  animation: brw-spin 0.8s linear infinite;
}
.brw-spinner.is-sm {
  width: 10px;
  height: 10px;
  border-width: 1.5px;
}
@keyframes brw-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .brw-dot,
  .brw-spinner,
  .brw-notice {
    animation: none !important;
  }
}

/* ---- "Through your proxy" chip (session route upstream) ---- */
.brw-route {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--blue);
  font-size: 11px;
  white-space: nowrap;
}
.brw-route[hidden] {
  display: none;
}
