/* Full-site gate when the browser has no internet (non-dashboard pages). */
html.akma-net-offline:not(.akma-net-soft-offline),
html.akma-net-offline:not(.akma-net-soft-offline) body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/*
 * Dashboard tile grid: never full-page cover or LAN-only top banner.
 * Stream overlay (stream-overlay-open) may show the LAN bar like /view.
 * Also kill legacy html.akma-net-unstable (that class used to display:none the
 * whole document because the strip shared the same class name).
 */
html[data-akma-page='dashboard'] #akma-net-gate,
html.akma-net-soft-offline #akma-net-gate {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
html[data-akma-page='dashboard']:not(.stream-overlay-open) #akma-net-lan-banner,
html[data-akma-page='dashboard']:not(.stream-overlay-open) #akma-net-lan-info {
  display: none !important;
}

/* Legacy mistaken html class — never hide the document again. */
html.akma-net-unstable {
  display: revert !important;
}

/* ── Dashboard: Network Unstable strip under app-header (CamWatch neu) ── */
.akma-net-unstable-strip {
  display: none;
  flex-shrink: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: transparent;
  /* Equal vertical pad so the pill sits centered between header and filter */
  padding: 8px 20px;
  box-sizing: border-box;
}

html.akma-net-soft-offline .akma-net-unstable-strip {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Me tab: no Network Unstable strip — options are disabled instead. */
html.akma-net-soft-offline.akma-tab-account .akma-net-unstable-strip {
  display: none !important;
}

.akma-net-unstable-strip[hidden] {
  display: none !important;
}

/* Soft raised pill: wifi circle + short label */
.akma-net-unstable-brand {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 7px 16px 7px 7px;
  border-radius: 999px;
  background: #e8eaf0;
  box-shadow:
    5px 5px 12px rgba(180, 185, 210, 0.5),
    -5px -5px 12px rgba(255, 255, 255, 0.92);
  text-align: left;
}

.akma-net-unstable-ico-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e8eaf0;
  color: rgba(70, 80, 130, 0.72);
  box-shadow:
    inset 3px 3px 7px rgba(165, 170, 200, 0.5),
    inset -3px -3px 7px rgba(255, 255, 255, 0.9);
}

.akma-net-unstable-ico {
  width: 20px;
  height: 20px;
  display: block;
  color: inherit;
}

.akma-net-unstable-badge {
  position: absolute;
  right: -2px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: #ef4444;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.85));
}

.akma-net-unstable-badge svg {
  width: 14px;
  height: 14px;
  display: block;
}

.akma-net-unstable-text {
  font-family: var(--font, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: rgba(70, 80, 130, 0.78);
  white-space: nowrap;
}

html.theme-dark .akma-net-unstable-brand,
html.theme-dark .akma-net-unstable-ico-wrap {
  background: var(--bg-card, #1a1c24);
}

html.theme-dark .akma-net-unstable-brand {
  box-shadow: var(--shadow-card-sm, 4px 4px 10px rgba(0, 0, 0, 0.4));
}

html.theme-dark .akma-net-unstable-ico-wrap {
  color: rgba(180, 185, 210, 0.78);
  box-shadow: var(--shadow-inset, inset 3px 3px 8px rgba(0, 0, 0, 0.45));
}

html.theme-dark .akma-net-unstable-text {
  color: rgba(180, 185, 210, 0.78);
}

html.theme-dark .akma-net-unstable-badge {
  color: #ff453a;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

/* Offline: keep brand in layout so actions stay right; just make it invisible. */
html.akma-net-soft-offline #app-header .header-brand {
  visibility: hidden !important;
  pointer-events: none !important;
}

/*
 * Soft-offline: drop the normal header→filter gap so the strip can sit
 * centered in that band (equal pad above/below the pill).
 */
html.akma-net-soft-offline #app-header {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

html.akma-net-soft-offline .filter-bar {
  padding-top: 0;
}

/* Soft-dim cloud-only controls while network is unstable (dashboard) */
html.akma-net-soft-offline #btn-add-camera,
html.akma-net-soft-offline #btn-sharing,
html.akma-net-soft-offline #btn-manage-cams,
html.akma-net-soft-offline #btn-notifications,
html.akma-net-soft-offline #btn-notif {
  opacity: 0.45;
}

#akma-net-gate {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  box-sizing: border-box;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 55%),
    #0c0d10;
  color: #f5f5f7;
  text-align: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

html.akma-net-offline:not(.akma-net-soft-offline) #akma-net-gate {
  display: flex;
  animation: akma-net-gate-in 0.35s ease both;
}

@keyframes akma-net-gate-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#akma-net-gate .akma-net-gate-card {
  position: relative;
  width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#akma-net-gate .akma-net-gate-orb {
  position: absolute;
  top: -28px;
  left: 50%;
  width: 180px;
  height: 180px;
  margin-left: -90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

#akma-net-gate .akma-net-gate-ico-wrap {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

#akma-net-gate .akma-net-gate-ico {
  width: 34px;
  height: 34px;
  color: #f5f5f7;
  opacity: 0.95;
}

#akma-net-gate .akma-net-gate-title {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

#akma-net-gate .akma-net-gate-msg {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 26ch;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.45;
  color: rgba(245, 245, 247, 0.72);
}

#akma-net-gate .akma-net-gate-hint {
  position: relative;
  z-index: 1;
  margin: 8px 0 0;
  max-width: 28ch;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 0.82rem;
  line-height: 1.4;
  color: rgba(245, 245, 247, 0.42);
}

html.theme-light #akma-net-gate {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(0, 0, 0, 0.04), transparent 55%),
    #f2f2f7;
  color: #1c1c1e;
}

html.theme-light #akma-net-gate .akma-net-gate-orb {
  background: radial-gradient(circle, rgba(0, 0, 0, 0.05), transparent 68%);
}

html.theme-light #akma-net-gate .akma-net-gate-ico-wrap {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.06);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
}

html.theme-light #akma-net-gate .akma-net-gate-ico {
  color: #1c1c1e;
}

html.theme-light #akma-net-gate .akma-net-gate-msg {
  color: rgba(28, 28, 30, 0.62);
}

html.theme-light #akma-net-gate .akma-net-gate-hint {
  color: rgba(28, 28, 30, 0.4);
}

/* ── LAN-only degraded mode (cloud down, local camera healthy) ── */
/*
 * Full-width bar directly under the stream box (#vidBox / #pbVidWrap).
 * Light blue surface; chevron opens the explanation sheet.
 */
#akma-net-lan-banner {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 9px 14px;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  background: #d7ebff;
  color: #0a3d7a;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  letter-spacing: -0.01em;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
  flex-shrink: 0;
}

html.theme-dark #akma-net-lan-banner {
  background: rgba(10, 132, 255, 0.22);
  color: #c8e2ff;
}

html.akma-net-lan-only #akma-net-lan-banner:not([hidden]) {
  display: flex;
}

#akma-net-lan-banner[hidden] {
  display: none !important;
}

#akma-net-lan-banner:active {
  opacity: 0.88;
}

/* Hide under maximized stream — bar is in document flow under the box. */
body.vid-expanded #akma-net-lan-banner,
#playbackView.pb-vid-expanded #akma-net-lan-banner {
  display: none !important;
}

.akma-net-lan-banner-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #0a84ff;
  opacity: 1;
}

html.theme-dark .akma-net-lan-banner-ico {
  color: #64b5ff;
}

.akma-net-lan-banner-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  text-wrap: balance;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.akma-net-lan-banner-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #0a84ff;
  opacity: 0.85;
}

html.theme-dark .akma-net-lan-banner-arrow {
  color: #64b5ff;
}

/* Soft-dim cloud-only dashboard controls while LAN-only */
html.akma-net-lan-only #btn-add-camera,
html.akma-net-lan-only #btn-sharing,
html.akma-net-lan-only #btn-manage-cams,
html.akma-net-lan-only #btn-notifications,
html.akma-net-lan-only #btn-notif {
  opacity: 0.45;
}

/* ── LAN-only explanation sheet ── */
#akma-net-lan-info {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity 0.22s ease;
}

#akma-net-lan-info.is-open {
  display: flex;
  opacity: 1;
}

#akma-net-lan-info[hidden] {
  display: none !important;
}

.akma-net-lan-info-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  max-height: 100%;
  background: #ffffff;
  color: #1c1c1e;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(12px);
  transition: transform 0.24s ease;
  overflow: hidden;
}

#akma-net-lan-info.is-open .akma-net-lan-info-panel {
  transform: translateY(0);
}

html.theme-dark .akma-net-lan-info-panel {
  background: #1c1c1e;
  color: #f5f5f7;
}

.akma-net-lan-info-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: max(10px, env(safe-area-inset-left, 0px));
  z-index: 2;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(120, 120, 128, 0.12);
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.akma-net-lan-info-close svg {
  width: 18px;
  height: 18px;
  display: block;
}

.akma-net-lan-info-close:active {
  opacity: 0.75;
}

.akma-net-lan-info-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(56px + env(safe-area-inset-top, 0px)) 28px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.akma-net-lan-info-title {
  margin: 0;
  max-width: 22ch;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.akma-net-lan-info-ico-wrap {
  width: 88px;
  height: 88px;
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(10, 132, 255, 0.12);
  color: #0a84ff;
  flex-shrink: 0;
}

html.theme-dark .akma-net-lan-info-ico-wrap {
  background: rgba(10, 132, 255, 0.18);
}

.akma-net-lan-info-ico {
  width: 34px;
  height: 34px;
  display: block;
}

.akma-net-lan-info-ico-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  color: #0a84ff;
}

.akma-net-lan-info-points {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  width: 100%;
  max-width: 34ch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.akma-net-lan-info-points li {
  position: relative;
  margin: 0;
  padding: 0 0 0 18px;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.45;
  color: rgba(28, 28, 30, 0.72);
}

html.theme-dark .akma-net-lan-info-points li {
  color: rgba(245, 245, 247, 0.72);
}

.akma-net-lan-info-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #0a84ff;
}

.akma-net-lan-info-footer {
  flex-shrink: 0;
  padding: 12px 20px max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  box-sizing: border-box;
  background: inherit;
  border-top: 1px solid rgba(60, 60, 67, 0.1);
}

html.theme-dark .akma-net-lan-info-footer {
  border-top-color: rgba(235, 235, 245, 0.12);
}

.akma-net-lan-info-understood {
  display: block;
  width: 100%;
  margin: 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: #0a84ff;
  color: #fff;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.akma-net-lan-info-understood:active {
  opacity: 0.9;
}
